Skip to content

Conversation

@westonganger
Copy link
Contributor

@westonganger westonganger commented Feb 7, 2019

Solves #11

  • Dont annotate errors to files
  • Squelch errors by default
  • Use config.debug = true to puts errors

Note: this is untested so far I merely wrote it.

Copy link
Owner

@7even 7even left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs some tests.

@westonganger
Copy link
Contributor Author

Tests added.

backticks = '# ```'
annotation.unshift(backticks).push(backticks)

if annotation.first.start_with?("# create_table")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Morozzzko will this work for views, or we need something like annotation.first.start_with?("# create_table") || annotation.first.start_with?("# create_view")? Can you tell us how the views look like in your app's annotations?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check and tell you by Tuesday evening

Copy link
Contributor

@Morozzzko Morozzzko Feb 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I'm late. It says create_table even if it's a view

Probably because it's a materialized view, not sure

create_table :table_name id: false, force: :cascade do |t|

end

@lines.unshift(*annotation, nil)
elsif configurator.debug
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be

Suggested change
elsif configurator.debug
elsif configurator.debug?

let(:configurator) {
c = ActiveRecord::Annotate::Configurator.new
c.debug = true
c
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to ActiveRecord::Annotate::Configurator.new.tap { |c| c.debug = true }.

expect(new_file).not_to be_changed
end
end

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant empty line.

### Doesnt add new annotation to non-annotated file
new_file.annotate_with(["error"], configurator)
expect(new_file).not_to be_changed
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the idea of this test. You are re-annotating the file with the same annotation and then checking that it didn't change :) Also the title assumes that old annotation should get removed which is not what happens here.

@westonganger
Copy link
Contributor Author

I have some other more important tasks on the go and you seem to have lots of comments and insight. Do you have any interest in picking up this PR and finishing it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants