Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocorrect errors #34

Closed
veelenga opened this issue Jan 31, 2018 · 8 comments
Closed

Autocorrect errors #34

veelenga opened this issue Jan 31, 2018 · 8 comments
Labels

Comments

@veelenga
Copy link
Member

veelenga commented Jan 31, 2018

The ability to autocorrect sources using a list of found errors. For example, me as a user seeing this error:

def has_user? # PredicateName: Favour method name 'user?' over 'has_user?'
end

would love to be able to automatically convert it to:

def user?
end

Should be doable with Crystal::Transformer. Here is a simple example:

https://github.com/crystal-lang/crystal/blob/master/samples/compiler/transformer_example.cr

@hugoabonizio
Copy link
Contributor

Awesome! But how to handle the cases where problems comes from third-party shards?

@veelenga
Copy link
Member Author

We don't inspect third-party shards. lib/ directory is excluded from the list of sources.

@hugoabonizio
Copy link
Contributor

Actually I was thinking in this case:

if OtherLib.has_something?
  # ...
end

But I didn't realised Ameba only checks for methods definitions, not calls. Sorry!

@veelenga
Copy link
Member Author

Ah, okay that is an interesting point. For this particular rule (PredicateName) that wouldn't be a case, because it is looking for the method definition, not the method call. So it will not report an error and there will be nothing to autocorrect. But there might be other rules which could do other inspections for third-party calls. Will keep this in mind, thank you.

@anicholson
Copy link

Oh yes please! I don't want to use a linter that doesn't fix the things it knows how to :)

@kostya
Copy link

kostya commented Jul 5, 2018

in my project i have ~500 errors: LargeNumbers: Large numbers should be written with underscores, replace it by hands is pain.

@veelenga
Copy link
Member Author

veelenga commented Jul 5, 2018

@kostya @anicholson any help is appreciated :)

Btw, LargeNumbers is now disabled by default in master.

@veelenga
Copy link
Member Author

Closed by

#248

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants