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

Implement NoInfer linter. #333

Merged
merged 3 commits into from
Sep 7, 2017
Merged

Implement NoInfer linter. #333

merged 3 commits into from
Sep 7, 2017

Conversation

olafurpg
Copy link
Contributor

@olafurpg olafurpg commented Sep 7, 2017

This is the first scalafix linter rule. There are still a few rough corners around how to display carets around synthetics but the api is already usable. It was a great exercise to implement this linter since I found a few necessary parts missing in testkit to make the experience nice.

- Add docs
- assert: instead of scalafix: in testkit
- Support empty string id in LintCategory
- Update Rule docstring to be cleaner.
@olafurpg olafurpg changed the title WIP - Implement NoInfer linter. Implement NoInfer linter. Sep 7, 2017
@olafurpg olafurpg merged commit 7371910 into scalacenter:master Sep 7, 2017
@olafurpg olafurpg deleted the no-infer branch September 7, 2017 12:34
@@ -95,7 +96,7 @@ abstract class SemanticRuleSuite(
val key = lintMessages.head.category.key(rule.name)
val explanation =
s"""|To fix this problem, suffix the culprit lines with
| // scalafix: $key
| // assert: $key
Copy link
Collaborator

Choose a reason for hiding this comment

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

how does the // assert comment work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can assert which linter message is reported at which specfic lines https://github.com/scalacenter/scalafix/blob/master/scalafix-tests/input/src/main/scala/test/NoInfer.scala#L7

The test fails if

  • the linter category doesn't match,
  • a message is not reported on that line
  • a message is reported at a line without an assert

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice! This is only for testkit right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is only testkit. Escape hatches for users are yet unimplemented #241

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.

2 participants