Skip to content

Conversation

mostafa
Copy link
Contributor

@mostafa mostafa commented Feb 1, 2024

In this PR I added a flag that enables basic stats collection and printing per linter using the --show-stats-per-linter flag to the run subcommand. This only prints the stats to the terminal after running all the linters.

Note to the reviewers:
I tried implementing it using e.runAnalysis to return the stats from the run.Run, yet it made things more complicated. I can still do it if you prefer that approach and I'd be happy to have your feedback. Also, I can either update the printers.Print interface to accept the stats or add a extra field (somewhere), so that the stats are printed based on the formatter used, and not just to the terminal.

Closes #2924.

Copy link

boring-cyborg bot commented Feb 1, 2024

Hey, thank you for opening your first Pull Request !

@CLAassistant
Copy link

CLAassistant commented Feb 1, 2024

CLA assistant check
All committers have signed the CLA.

@ldez ldez self-requested a review February 1, 2024 15:32
@ldez ldez added area: CLI Related to CLI enhancement New feature or improvement labels Feb 1, 2024
@ldez ldez changed the title Implement stats per linter with a flag cli: implement stats per linter with a flag Feb 2, 2024
@ldez ldez changed the title cli: implement stats per linter with a flag feat: implement stats per linter with a flag Feb 2, 2024
@ldez
Copy link
Member

ldez commented Feb 2, 2024

Hello,

I made some modifications:

  • Replaced --show-stats-per-linter by --show-stats.

  • Changed the output:

    Before
    Stats per linter:
      goconst: 1
      tagalign: 1
      inamedparam: 5
      musttag: 1
      perfsprint: 50
      nolintlint: 1
      typecheck: 2
      gofumpt: 1
      protogetter: 20
      testifylint: 50
    

    Note: the order of linters is not deterministic (because of a map).

    Stats per linter:
      no issues
    
    After
    132 issues:
    * goconst: 1
    * gofumpt: 1
    * inamedparam: 5
    * musttag: 1
    * nolintlint: 1
    * perfsprint: 50
    * protogetter: 20
    * tagalign: 1
    * testifylint: 50
    * typecheck: 2
    

    Note: the order of linters is deterministic (alphabetic order).

    0 issues.
    
  • Added the option to the documentation.

@ldez ldez force-pushed the show-stats-per-linter branch from 421db27 to 2151d87 Compare February 2, 2024 15:02
@mostafa
Copy link
Contributor Author

mostafa commented Feb 2, 2024

@ldez

Awesome! Thanks! 🙏

Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution to golangci-lint.
Your PR will benefit many users.

@mostafa
Copy link
Contributor Author

mostafa commented Feb 2, 2024

@ldez

Thanks for tending to it so quickly! 🙏

Co-authored-by: Anton Telyshev <[email protected]>
@ldez ldez enabled auto-merge (squash) February 2, 2024 19:23
@ldez ldez merged commit b3ffe70 into golangci:master Feb 2, 2024
@mostafa mostafa deleted the show-stats-per-linter branch February 2, 2024 23:16
@ldez ldez modified the milestone: v1.56 Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: CLI Related to CLI enhancement New feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report count of issues shown for a particular linter type

5 participants