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

RegexpWarnings in Goland #235

Closed
Tommi2Day opened this issue Jan 14, 2024 · 4 comments · Fixed by #237
Closed

RegexpWarnings in Goland #235

Tommi2Day opened this issue Jan 14, 2024 · 4 comments · Fixed by #237
Labels
bug Something isn't working linting range
Milestone

Comments

@Tommi2Day
Copy link

just to let you know Jetbrains Goland raises serveral RegExp warnings in range.go, which are causing force commits with changed code

Warning:(83, 49) Redundant character escape '\@' in RegExp
Warning:(83, 53) Unnecessary non-capturing group '(?:[-+]?[\d\.]+)'
Warning:(83, 64) Redundant character escape '\.' in RegExp
Warning:(83, 73) Unnecessary non-capturing group '(?:[-+]?[\d\.]+)'
Warning:(83, 84) Redundant character escape '\.' in RegExp
Warning:(83, 98) Unnecessary non-capturing group '(?:[-+]?[\d\.]+)'
Warning:(83, 109) Redundant character escape '\.' in RegExp
Warning:(83, 118) Unnecessary non-capturing group '(?:[-+]?[\d\.]+)'
Warning:(83, 129) Redundant character escape '\.' in RegExp
Warning:(84, 44) Unnecessary non-capturing group '(?:[-+]?[\d\.]+)'
Warning:(84, 55) Redundant character escape '\.' in RegExp
Warning:(84, 64) Unnecessary non-capturing group '(?:[-+]?[\d\.]+)'
Warning:(84, 75) Redundant character escape '\.' in RegExp
Warning:(85, 37) Unnecessary non-capturing group '(?:[-+]?[\d\.]+)'
Warning:(85, 48) Redundant character escape '\.' in RegExp
Warning:(85, 57) Unnecessary non-capturing group '(?:[-+]?[\d\.]+)'
Warning:(85, 68) Redundant character escape '\.' in RegExp
@atc0005
Copy link
Owner

atc0005 commented Jan 15, 2024

@Tommi2Day Thanks for sharing this.

Does that IDE offer an option to automatically fix the regex patterns or an alternative?

@Tommi2Day
Copy link
Author

partially yes. You can go through the positions complained and add "suggested Action"
image

@Tommi2Day
Copy link
Author

this is a version with all suggestions adopted. Unit test ran sucessfully

digitOrInfinity := regexp.MustCompile([\d~])
optionalInvertAndRange := regexp.MustCompile(^@?([-+]?[\d.]+(?:e[-+]?[\d.]+)?|~)?(:([-+]?[\d.]+(?:e[-+]?[\d.]+)?)?)?$)
firstHalfOfRange := regexp.MustCompile(^([-+]?[\d.]+(?:e[-+]?[\d.]+)?)?:)
endOfRange := regexp.MustCompile(^[-+]?[\d.]+(?:e[-+]?[\d.]+)?$)

Tommi2Day pushed a commit to Tommi2Day/go-nagios that referenced this issue Jan 15, 2024
@atc0005 atc0005 added bug Something isn't working linting range labels Jan 16, 2024
@atc0005
Copy link
Owner

atc0005 commented Jan 16, 2024

@Tommi2Day Thanks for sharing. That linting feature looks like it would really come in handy.

@atc0005 atc0005 added bug Something isn't working and removed bug Something isn't working labels Jan 16, 2024
@atc0005 atc0005 added this to the Next Release milestone Jan 16, 2024
Tommi2Day pushed a commit to Tommi2Day/go-nagios that referenced this issue Jan 16, 2024
Tommi2Day pushed a commit to Tommi2Day/go-nagios that referenced this issue Jan 16, 2024
Tommi2Day pushed a commit to Tommi2Day/go-nagios that referenced this issue Jan 16, 2024
Tommi2Day pushed a commit to Tommi2Day/go-nagios that referenced this issue Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linting range
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants