diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index aa519ba7f..5c06215e0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -408,7 +408,7 @@ Lint/ShadowingOuterLocalVariable: # Offense count: 20 Metrics/AbcSize: - Max: 138 + Max: 139 # Offense count: 28 # Configuration parameters: CountComments, ExcludedMethods. diff --git a/lib/annotate/annotate_models.rb b/lib/annotate/annotate_models.rb index b306d0b84..56b358bea 100644 --- a/lib/annotate/annotate_models.rb +++ b/lib/annotate/annotate_models.rb @@ -305,7 +305,7 @@ def get_schema_info(klass, header, options = {}) if options[:format_rdoc] info << sprintf("# %-#{max_size}.#{max_size}s%s", "*#{col_name}*::", attrs.unshift(col_type).join(", ")).rstrip + "\n" elsif options[:format_markdown] - name_remainder = max_size - col_name.length + name_remainder = max_size - col_name.length - non_ascii_length(col_name) type_remainder = (md_type_allowance - 2) - col_type.length info << (sprintf("# **`%s`**%#{name_remainder}s | `%s`%#{type_remainder}s | `%s`", col_name, " ", col_type, " ", attrs.join(", ").rstrip)).gsub('``', ' ').rstrip + "\n" else @@ -932,6 +932,10 @@ def mb_chars_ljust(string, length) string[0..length-1] end end + + def non_ascii_length(string) + string.to_s.chars.reject(&:ascii_only?).length + end end class BadModelFileError < LoadError