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

Improve regex integration with DisableSyntax #907

Merged
merged 8 commits into from Nov 28, 2018

Conversation

Jacoby6000
Copy link
Contributor

@Jacoby6000 Jacoby6000 commented Nov 13, 2018

I think the best way to see what I've changed is to look at the updated docs. To summarize:

  1. Now error messages will underline the whole area of matched regex
  2. The relevant capture group can be specified, in case you have complicated regex's which may match on parts which aren't helpful in the error message
  3. scalafix errors which came from a regex match have access to the capture groups for substitution in the error messages.

I'm not dead set on any of the naming or formatting I've chosen. Feel free to have me change them

@Jacoby6000
Copy link
Contributor Author

My current example is the magicNumber thing, and I don't like it. Just couldn't come up with a generic rule that has more complex regex.

Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

This looks great @Jacoby6000 Thank you for this contribution! I left a few minor comments, otherwise great job 👍

]
```

1. The first way has a simple object providing an `id`, `pattern`, and `message`.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/simple//


### Error Messages

Error messages have access to the capture groups of the regex. Simply use `{$n}`
Copy link
Contributor

Choose a reason for hiding this comment

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

To access to the capture groups of the regex use {$n} ...

@@ -52,8 +60,12 @@ case object DisableSyntaxBase {
def -(other: String): String = s"$value - $other"
}

5 // assert: DisableSyntax.magicNumbers
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we assert the contents of the message here?

 5 /* assert: DisableSyntax.magicNumbers
 ^
 Numbers (5 in this instance) should always ...
*/

See end of this section https://scalacenter.github.io/scalafix/docs/developers/tutorial.html#use-diagnostic-to-report-linter-errors

@Jacoby6000
Copy link
Contributor Author

Thanks for the feedback. I believe I've addressed all the comments

Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

LGTM 👍 I thought this has already been merged a long time ago, sorry for the slow response @Jacoby6000 I'm releasing a new version today with this change 😊

@olafurpg olafurpg merged commit 1547da5 into scalacenter:master Nov 28, 2018
@olafurpg olafurpg added this to the 0.9.1 milestone Nov 29, 2018
bjaglin added a commit that referenced this pull request Feb 15, 2022
 fix docs: reflect new param signature after #907
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.

None yet

2 participants