jgautheron / Goconst
Licence: mit
Find in Go repeated strings that could be replaced by a constant
Stars: ✭ 201
Programming Languages
go
31211 projects - #10 most used programming language
Labels
Projects that are alternatives of or similar to Goconst
Sublimelinter
The code linting framework for Sublime Text 3
Stars: ✭ 1,920 (+855.22%)
Mutual labels: linter
Eslint Config Standard
ESLint Config for JavaScript Standard Style
Stars: ✭ 2,229 (+1008.96%)
Mutual labels: linter
Poetic
Automatically install and maintain ESLint, Prettier, EditorConfig and Airbnb rules for JavaScript, TypeScript and React.
Stars: ✭ 165 (-17.91%)
Mutual labels: linter
Ue4 Style Guide
An attempt to make Unreal Engine 4 projects more consistent
Stars: ✭ 2,656 (+1221.39%)
Mutual labels: linter
Flake8 Eradicate
Flake8 plugin to find commented out or dead code
Stars: ✭ 184 (-8.46%)
Mutual labels: linter
Clippy Check
📎 GitHub Action for PR annotations with clippy warnings
Stars: ✭ 159 (-20.9%)
Mutual labels: linter
Pre Commit Hooks
Some out-of-the-box hooks for pre-commit
Stars: ✭ 2,605 (+1196.02%)
Mutual labels: linter
Zlint
X.509 Certificate Linter focused on Web PKI standards and requirements.
Stars: ✭ 190 (-5.47%)
Mutual labels: linter
Deal
Design by contract for Python with static checker and tests' generation.
Stars: ✭ 164 (-18.41%)
Mutual labels: linter
Add Trailing Comma
A tool (and pre-commit hook) to automatically add trailing commas to calls and literals.
Stars: ✭ 168 (-16.42%)
Mutual labels: linter
Diagnostic Languageserver
diagnostic language server integrate with linters
Stars: ✭ 186 (-7.46%)
Mutual labels: linter
Textlint
The pluggable natural language linter for text and markdown.
Stars: ✭ 2,158 (+973.63%)
Mutual labels: linter
Bodyclose
Analyzer: checks whether HTTP response body is closed and a re-use of TCP connection is not blocked.
Stars: ✭ 181 (-9.95%)
Mutual labels: linter
Spotbugs
SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.
Stars: ✭ 2,569 (+1178.11%)
Mutual labels: linter
Diktat
Strict coding standard for Kotlin and a custom set of rules for detecting code smells, code style issues and bugs
Stars: ✭ 196 (-2.49%)
Mutual labels: linter
goconst
Find repeated strings that could be replaced by a constant.
Motivation
There are obvious benefits to using constants instead of repeating strings, mostly to ease maintenance. Cannot argue against changing a single constant versus many strings.
While this could be considered a beginner mistake, across time, multiple packages and large codebases, some repetition could have slipped in.
Get Started
$ go get github.com/jgautheron/goconst/cmd/goconst
$ goconst ./...
Usage
Usage:
goconst ARGS <directory>
Flags:
-ignore exclude files matching the given regular expression
-ignore-tests exclude tests from the search (default: true)
-min-occurrences report from how many occurrences (default: 2)
-min-length only report strings with the minimum given length (default: 3)
-match-constant look for existing constants matching the values
-numbers search also for duplicated numbers
-min minimum value, only works with -numbers
-max maximum value, only works with -numbers
-output output formatting (text or json)
-set-exit-status Set exit status to 2 if any issues are found
Examples:
goconst ./...
goconst -ignore "yacc|\.pb\." $GOPATH/src/github.com/cockroachdb/cockroach/...
goconst -min-occurrences 3 -output json $GOPATH/src/github.com/cockroachdb/cockroach
goconst -numbers -min 60 -max 512 .
Other static analysis tools
- gogetimports: Get a JSON-formatted list of imports.
- usedexports: Find exported variables that could be unexported.
License
MIT
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].