drwl / annotaterb

A Ruby Gem that adds annotations to your Rails models and route files.
Other
191 stars 18 forks source link

Bug (apparently): :ignore_columns does not work (with any syntax I've tried) #154

Closed brandondrew closed 1 month ago

brandondrew commented 2 months ago

I've tried to ignore several columns, and have not had any success with any syntax that seems plausible. Since there are other settings that have (empty) arrays, it seemed like these might be expected on a single line as an array, so tried using square brackets with the fields inside, but I also tried without the square brackets. I tried naming the fields with bare words, single- and double-quoted names, and symbol syntax. None of that worked. I also tried putting the fields on subsequent lines using normal YAML syntax. None of that worked either.

There is nothing I see that serves as an example.

Permutations Attempted

:ignore_columns: [:created_at, :updated_at]
:ignore_columns: ['created_at', 'updated_at']
:ignore_columns: ["created_at", "updated_at"]
:ignore_columns: [created_at, updated_at]
:ignore_columns: :created_at, :updated_at
:ignore_columns: 'created_at', 'updated_at'
:ignore_columns: "created_at", "updated_at"
:ignore_columns: created_at, updated_at
:ignore_columns:
- :created_at
- :updated_at
:ignore_columns:
- 'created_at'
- 'updated_at'
:ignore_columns:
- "created_at"
- "updated_at"
:ignore_columns:
- created_at
- updated_at

The first one results in

bundler: failed to load command: annotaterb (/Users/brandon/.rbenv/versions/3.3.5/bin/annotaterb)
/Users/brandon/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/psych-3.3.4/lib/psych.rb:457:in `parse': (/Users/brandon/Code/Rails/portal/.annotaterb.yml): did not find expected node content while parsing a flow node at line 43 column 19 (Psych::SyntaxError)

The second, third, fourth, ninth, tenth, eleventh, and twelfth permutations all result in

bundler: failed to load command: annotaterb (/Users/brandon/.rbenv/versions/3.3.5/bin/annotaterb)
/Users/brandon/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/annotaterb-4.12.0/lib/annotate_rb/model_annotator/model_wrapper.rb:103:in `max_schema_info_width': undefined method `+' for nil (NoMethodError)

            max_size += @options[:format_rdoc] ? 5 : 1

The fifth and eigth permutations don't give any errors, but fail to filter out the specified columns.

The sixth and seventh permutations showed YAML errors in my editors, and result in

bundler: failed to load command: annotaterb (/Users/brandon/.rbenv/versions/3.3.5/bin/annotaterb)
/Users/brandon/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/psych-3.3.4/lib/psych.rb:457:in `parse': (/Users/brandon/Code/Rails/portal/.annotaterb.yml): did not find expected key while parsing a block mapping at line 2 column 1 (Psych::SyntaxError)

Unless I'm failing to see a possibility, it appears that filtering columns is not working.

Versions

drwl commented 1 month ago

Thanks for reporting this and apologies for the long delay. I recently started a job and have been trying to ramp up quickly. I'll take an initial look at this in my evening.

brandondrew commented 1 month ago

thanks for your time!

drwl commented 1 month ago

Took a look, so for that option, it looks like you just need to pass a regex. It doesn't seem to support column names directly.

For example, annotaterb models -I '(id|updated_at|created_at)' this works in the CLI, and you can use the non-quoted version in the yml file.

brandondrew commented 1 month ago

ahh, okay, that's useful, although it never occurred to me to try a regular expression.

brandondrew commented 1 month ago

It might be a good idea to add something like that as an example in the comments near that key

:ignore_columns: # (id|updated_at|created_at)