Skip to content

refactor: replace package-level vars with simpler code - #1966

Merged
alexandear merged 1 commit into
revive-lint:masterfrom
alexandear:refactor/global-vars
Nov 13, 2026
Merged

alexandear merged 1 commit into
revive-lint:masterfrom
alexandear:refactor/global-vars

Conversation

@alexandear

Copy link
Copy Markdown
Member

Important

This PR removes AppFs. It was added in #912 but hasn't been used since then (see sourcegraph).

Fixes #1965

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the package-state simplification and removal of the AppFs abstraction.

No open issues 🎉

What changed in this PR

This PR simplifies package-level state in revive, addressing #1965 by replacing avoidable variables with constants or local values. It also removes the AppFs abstraction introduced in #912 and its dependencies.

Changes:

  • Pass CLI settings through a local options struct and use os.Stat for config-file checks.
  • Replace fixed-value variables with constants and comment-prefix regular expressions with string checks.
  • Remove the afero and indirect golang.org/x/text dependencies.
File Description
rule/​time_date.go Use a fixed-size argument array and constant arity.
rule/​get_return.go Make the getter-prefix length a constant.
rule/​file_header.go Replace prefix regular expressions with strings.HasPrefix.
rule/​defer.go Define normalized option names as constants.
lint/​package.go Make boolean sentinel values constants.
go.sum Remove checksums for removed dependencies.
go.mod Remove afero and indirect golang.org/x/text requirements.
cli/​main.go Localize CLI options and usage capture; replace AppFs with os.Stat.

Review effort: Balanced

@alexandear
alexandear merged commit e9925b6 into revive-lint:master Nov 13, 2026
15 checks passed
@alexandear
alexandear deleted the refactor/global-vars branch November 13, 2026 17:53

@ccoVeille ccoVeille left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Depending on cli package to get this variable sounds indeed unlikely

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.

Replace avoidable package-level variables with constants or simpler code

3 participants