Skip to content

Verify the .golangci.yaml config #2645

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

Closed
bwagner5 opened this issue Mar 11, 2022 · 9 comments · Fixed by #4527
Closed

Verify the .golangci.yaml config #2645

bwagner5 opened this issue Mar 11, 2022 · 9 comments · Fixed by #4527
Assignees
Labels
area: JSON schema enhancement New feature or improvement

Comments

@bwagner5
Copy link

Your feature request related to a problem? Please describe.

Crafting the .golangci.yaml can be a little challenging as the config grows or just getting right the first time. For example, I was crafting a config and had my indention off for the linters-settings: and rather than error'ing, the linter-settings were just not applied.

Describe the solution you'd like.

I propose a verify command is added to the golangci-lint CLI tool that will verify the config schema.

Describe alternatives you've considered.

Alternatively, golangci-lint run could throw an error when the config does not conform to the top-level schema.

Additional context.

No response

@bwagner5 bwagner5 added the enhancement New feature or improvement label Mar 11, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Mar 11, 2022

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez ldez self-assigned this Mar 11, 2022
@mateusoliveira43
Copy link
Contributor

Maybe related to this issue #1453

I was trying to do this by a separate command, but found problems.

the idea was to use https://github.com/santhosh-tekuri/jsonschema with https://json.schemastore.org/golangci-lint.json (per #4247 (reply in thread))

Example of command

jv -output detailed https://json.schemastore.org/golangci-lint.json ./.golangci.yaml

But https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/golangci-lint.json is not up to date with https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml (missing fields, like output.sort-results, and I think validations to do not allow properties outside from declared ones). If an automation could be created to update that file on each release from this repo, maybe this idea could be used in verify command.

Also, if verify command could check if user is using deprecated linters and is using last release of golangci-lint, would be awesome!

@ldez
Copy link
Member

ldez commented Dec 12, 2023

But https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/golangci-lint.json is not up to date with https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml (missing fields, like output.sort-results, and I think validations to do not allow properties outside from declared ones). If an automation could be created to update that file on each release from this repo, maybe this idea could be used in verify command.

The branch master is not the latest stable release, it's the current dev branch.
The JSON schema is related to the latest release (v1.55.2).
I update the JSON schema after each release.

https://github.com/SchemaStore/schemastore/pulls?q=is%3Apr+author%3Aldez+is%3Aclosed

@mateusoliveira43
Copy link
Contributor

Checked the file in the release tag https://github.com/golangci/golangci-lint/blob/e3c2265f4939976874989e159386b3bb7dcf8e1f/.golangci.reference.yml and it really has output.sort-results, which https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/golangci-lint.json does not have. How is the process of updating this file is SchemaStore/schemastore repo? I would like to help with it 😄

@ldez
Copy link
Member

ldez commented Dec 13, 2023

It's just a mistake.
I fixed the problem SchemaStore/schemastore#3438

The contribution guide to SchemaStore repo is here: https://github.com/SchemaStore/schemastore/blob/master/CONTRIBUTING.md
If you create a PR on this repo you can ping me for the review.

@mateusoliveira43

This comment was marked as off-topic.

@mateusoliveira43
Copy link
Contributor

just an update, https://json.schemastore.org/golangci-lint.json is now up to date with last release.

So, the idea of using https://github.com/santhosh-tekuri/jsonschema with https://json.schemastore.org/golangci-lint.json for checking latest release config file is valid. Example

jv -output detailed https://json.schemastore.org/golangci-lint.json ./.golangci.yaml

If this schema could be shipped with each release, we could add similar solution for each release, and not only latest.

A idea for next release is to run this command against https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml prior to release. If can catch missing fields in the schema

@bombsimon
Copy link
Member

Is the issue to be able to verify the .golangci.yaml config resolved by having a JSON schema (given that it's up to date, which it should be) or do we need to keep this issue open for other reasons?

@ldez
Copy link
Member

ldez commented Mar 11, 2024

The issue is about a CLI command to verify the configuration, even if I thing it's better to use JSON schema inside an IDE or text editor, we can do something.
It's one of the topic I'm working on, but several steps are required before doing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: JSON schema enhancement New feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants