Skip to content

Conversation

abhijeetviswa
Copy link

@abhijeetviswa abhijeetviswa commented May 23, 2025

The majority of unused declarations were one of these types:

  • Global constants in generated files.
    • These files were completely ignored instead of modifying them.
  • Compile time type assertions.
    • These assignments were made to the blank identifier _
  • Unused function and fields in structs. These were removed.

@abhijeetviswa abhijeetviswa requested review from a team as code owners May 23, 2025 06:32
@abhijeetviswa abhijeetviswa marked this pull request as draft May 23, 2025 06:32
mukeshjc
mukeshjc previously approved these changes May 26, 2025
@abhijeetviswa
Copy link
Author

Took a look at this PR and realised the nolint directives can be avoided with some "clever" rewrites:

  • hclsyntax/scan_string_lit.go and hclsyntax/scan_tokens.go are generated files. Modifying them didn't to ignore lint errors didn't make sense. These files are ignored completely through .golangci.yaml. These files were regenerated using ragel and staticcheck error fixes made in 314d236 have been undone.
  • Compile time type assertions are being assigned to the blank identifier _ instead.

Copy link
Author

Choose a reason for hiding this comment

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

This file was regenerated by running go generate ./hclsyntax/generate.go and undoes changes made in 314d236.

Copy link
Author

Choose a reason for hiding this comment

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

This file was regenerated by running go generate ./hclsyntax/generate.go and undoes changes in 314d236.

Abhijeet V added 4 commits June 2, 2025 12:25
The majority of unused declarations were one of 3 types:
  - Global constants or sentinel variables. These were untouched becuse
    they serve as documentation and may become useful in the future.
  - Variable declarations to assert a struct implements an interface.
    These are compile time safety nets and were also ountouched.
  - Runtime function
  - Unused fields in structs. These were removed to reduce overall
    since they serve no purpose and at best increase memory consumption
    and at worst make such structs more confusing to the reader.

There was also an undocumented private function that was removed.  It
was straightforward and can be reimplemented if need be.
adding nolint directives to the generates files don't make sense if they
get rewritten. Instead, the errors are being ignored through the
golangci-lint config file.
@abhijeetviswa abhijeetviswa marked this pull request as ready for review June 2, 2025 07:54
@abhijeetviswa abhijeetviswa merged commit 61bd79d into main Jun 2, 2025
15 checks passed
@abhijeetviswa abhijeetviswa deleted the lint-unused branch June 2, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants