| name | code-quality |
| description | Measure and improve code quality: linting, complexity analysis, coverage reports, tech debt tracking, and formatting enforcement. |
| metadata | {"thinkfleetbot":{"emoji":"📊","requires":{"anyBins":["eslint","ruff","golangci-lint","clippy"]}}} |
Code Quality
Measure, enforce, and improve code quality across languages.
Linting
JavaScript/TypeScript
npx eslint src/ --format json | jq '[.[] | select(.errorCount > 0 or .warningCount > 0) | {file: .filePath, errors: .errorCount, warnings: .warningCount}]'
npx eslint src/ --fix
npx eslint src/ --rule '{"no-unused-vars": "error"}'
Python
ruff check src/
ruff check src/ --fix
mypy src/ --ignore-missing-imports
ruff check src/ && mypy src/
Go
golangci-lint run ./...
golangci-lint run --enable gosec,govet,errcheck,staticcheck ./...
golangci-lint run --out-format json ./... | jq '.Issues[] | {file: .Pos.Filename, line: .Pos.Line, linter: .FromLinter, text: .Text}'
Rust
cargo clippy -- -W clippy::all
cargo clippy -- -D warnings
cargo clippy --fix
Formatting
npx prettier --check "src/**/*.{ts,tsx,js,jsx}"
npx prettier --write "src/**/*.{ts,tsx,js,jsx}"
ruff format src/
ruff format --check src/
gofmt -l .
gofmt -w .
cargo fmt --check
cargo fmt
Code Coverage
npx jest --coverage --json | jq '{lines: .coverageMap | to_entries | map(.value.s | to_entries | map(.value) | {total: length, covered: map(select(. > 0)) | length}) | {total: map(.total) | add, covered: map(.covered) | add} | {pct: (100 * .covered / .total | floor)}}'
npx jest --coverage 2>&1 | tail -10
pytest --cov=src --cov-report=term-missing
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out | tail -1
cargo tarpaulin --out stdout
Complexity Metrics
radon cc src/ -a -s -nb
radon mi src/ -s -nb
npx eslint src/ --rule '{"complexity": ["warn", 10]}' --format json | jq '[.[] | .messages[] | select(.ruleId == "complexity") | {file: input.filePath, line: .line, message: .message}]'
Tech Debt Indicators
Look for these patterns:
grep -rn "TODO\|FIXME\|HACK\|XXX\|TEMP" src/ --include="*.ts" --include="*.py" --include="*.go" | wc -l
grep -rn "TODO\|FIXME\|HACK" src/ --include="*.ts" --include="*.py"
find src/ -name "*.ts" -o -name "*.py" | xargs wc -l | sort -rn | head -20
pylint --disable=all --enable=duplicate-code src/
Notes
- Run linting on changed files only in CI for speed:
eslint $(git diff --name-only --diff-filter=ACMR HEAD~1 | grep -E '\.(ts|tsx|js)$').
- Coverage percentage alone is misleading — 80% with no edge case tests is worse than 60% with thorough tests.
- Fix linting errors incrementally. Don't dump 500 fixes into one commit.
- Complexity > 10 is a code smell. > 20 needs refactoring.