-
Notifications
You must be signed in to change notification settings - Fork 42
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
Output with patterns isn't expanded when patterns match long (> 60 character) identifiers. #70
Comments
When outputing results the current behavior is to use the key in the output if the identifier would be too long for example: "$f != nil" This instead truncates the value and adds elisis as follows: "ThisIsAReallyLongIdentifierThatWillBeTruncatedInsteadOfReje... != nil" This output is more friendly. Addresses quasilyte#70
After thinking about this more perhaps a better solution would be to truncate the value instead of increasing the limit. PR for truncating the value #71 |
Since ruleguard is a CLI tool, it's always good to have a human-readable output that does not annoy the user. With matcher variables, there is a risk that submatch will be huge. For example, it may occupy several source lines (100+) if you're matching the statement. Everything inside that statement will be embedded in the message. This will make a single message 1000+ characters long, which might be disappointing as it clutters the output. The limit was a solution to filter out things that we probably don't want to interpolate. Your truncation idea is good as well, although it doesn't help with statements a lot (a more structural truncation/shortening would be better here). |
Running
ruleguard -rules rules.go -fix example.go
outputs "$f should be expanded to the name" but expected the output "ZeroOneTwoThreeFourFiveSixSevenEightNineTenElevenTwelveThirte should be expanded to the name" when executed with the following files.example.go
rules.go
This appears to be related to the limit placed here: https://github.com/quasilyte/go-ruleguard/blob/master/ruleguard/runner.go#L191
This limit was bumped from 40 to 60 in #63
Since many engineers use long function names for unit tests (BDD) I suggest the limit be increased to at least 120 (or removed altogether). An example of a long unit test function name could be.
func TestRuleguardOutput_CorrectlyExpandsMatchingVariablesWhenMatchingLongIdentifiers(t *testing.T) {
The text was updated successfully, but these errors were encountered: