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

tools/agentlint: add linter for river tags #2891

Merged
merged 3 commits into from
Feb 1, 2023

Conversation

rfratto
Copy link
Member

@rfratto rfratto commented Feb 1, 2023

Extend tools/agentlint with a linter for river tags, which will help catch improper usages of tags where unit tests for unmarshaling aren't present (first seen in #2629).

Linting rules can be skipped when necessary by adding a //nolint:rivertags comment.

Run: run,
}

var noLintRegex = regexp.MustCompile(`//\s*nolint:rivertags`)
Copy link
Member

Choose a reason for hiding this comment

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

In some places in our codebase we do something like this: //nolint:golint,rivertags. Can we amend the regex to catch this as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure! Doing it at the regex level felt ugly, but I changed my approach to support this 👍

} else if len(nameParts) > 1 {
diagnostics = append(diagnostics, "attr field names must not contain `.`")
}
for _, name := range nameParts {
Copy link
Member

Choose a reason for hiding this comment

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

There's always going to be 1 element in nameParts here, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I'm iterating over it anyway just in case they incorrectly put more than one, it's still useful (imo) to show the various errors across all the name fragments..

Copy link
Member

@tpaschalis tpaschalis left a comment

Choose a reason for hiding this comment

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

LGTM, easy to follow!

@rfratto rfratto enabled auto-merge (squash) February 1, 2023 16:09
@rfratto rfratto merged commit dda9aae into grafana:main Feb 1, 2023
@rfratto rfratto deleted the lint-rivertags branch February 1, 2023 17:07
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Mar 10, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants