Linters & Formatters
Formatters, lint rule engines and static type checkers for each ecosystem, from ESLint and Prettier to ruff, RuboCop and golangci-lint. Asked because the formatter/linter split shapes every CI gate.
on this pageshowhide
explore
- ESLintempty
- Rules & Severityempty
- Flat Configempty
- Prettierempty
- Biomeempty
- blackempty
- ruffempty
- mypyempty
- pyrightempty
- Ktlint2 questions
- Detekt4 questions
- golangci-lintempty
- goimportsempty
- PHPStan10 questions
- Rule Levels & Config5 questions
- Baselines & PHPDoc Types5 questions
- PHP CS Fixer6 questions
- PHPCodeSniffer6 questions
- RuboCop18 questions
- Departments & Cop Settings6 questions
- Autocorrect & Todo Files6 questions
- Standard Ruby6 questions
- SwiftLintempty
- SwiftFormatempty
- shellcheckempty
- StyleCopempty
questions
page 2 of 2How would you use PHP CS Fixer to reformat a whole PHP codebase to PER Coding Style in one commit without disrupting the team?
basics
~20 sPin PHP CS Fixer and a versioned set such as @PER-CS3x0, keep risky rules out, preview with check --diff, apply fix in a commit that contains nothing else, list that commit in .git-blame-ignore-revs, and start enforcing with check.
In PHP CS Fixer, what makes a rule risky, and how should a team enable risky rules with --allow-risky or setRiskyAllowed()?
basics
~10 sA risky PHP CS Fixer rule is one whose rewrite can change how the code behaves, such as strict_param or declare_strict_types; they run only when the config calls setRiskyAllowed(true) or the command passes --allow-risky=yes.
When would you choose PHP CS Fixer over PHP_CodeSniffer, or run both, to enforce a PHP team's coding style?
basics
~20 sPHP CS Fixer suits teams that want every rule fixed automatically, including modernising and risky rewrites; PHP_CodeSniffer suits teams that must also report conventions no tool can fix. Running both works when only one of them owns layout.
How would you use PHPStan's @template to type a collection class so that its elements keep their type through add(), get() and foreach?
basics
~20 sDeclare @template T above the class, use T in @param and @return tags, declare @implements IteratorAggregate<int, T> for foreach, and type usages as Collection<User>; PHPStan then infers User from get() and foreach and rejects adding other types.
What do PHPStan's Bleeding Edge and the phpstan-strict-rules extension each add beyond rule levels, and how do you enable them?
basics
~10 sBleeding Edge, enabled by including phar://phpstan.phar/conf/bleedingEdge.neon, turns on the next major version's rules and behaviour early; phpstan-strict-rules is an opinionated extension of extra checks, enabled through phpstan/extension-installer or by including its rules.neon.
You are introducing PHPStan into a 300,000-line legacy PHP codebase; how do you choose the starting level and configure the first runs?
basics
~20 sStart at level 0 over your own code only, fix configuration noise such as unknown classes with scanDirectories, bootstrapFiles and framework extensions, get to zero, gate CI there, then raise one level at a time, expecting level 6 to be the big jump.
After a one-off rubocop -A run on a Ruby 4.0 app, tests fail with FrozenError and NoMethodError; what did the run change, and how should it have been done?
basics
~20 srubocop -A applied corrections marked unsafe: the frozen-string-literal comment froze mutated literals (FrozenError), and x && x.foo became x&.foo, which breaks when x is false. Run -a first, then -A one cop at a time with tests between.
In RuboCop, what does rubocop --auto-gen-config write into .rubocop_todo.yml, and how do you keep that todo file shrinking instead of rotting?
basics
~20 s--auto-gen-config writes .rubocop_todo.yml, which excludes each offending file per cop (up to 15, then disables the cop) or raises Metrics Max values, and links it via inherit_from. Delete entries as you fix code; --report-unused-todo-entries fails on stale ones.
After a RuboCop upgrade, a run warns about pending cops and about `require: rubocop-performance` - what does each warning mean, and how do you fix the .rubocop.yml?
basics
~20 sPending cops are new cops that stay off until you decide; set each one's Enabled, or NewCops for all or per department. The require: warning means the gem is now a plugin, so list it under plugins: instead.
How do you add rules to Standard Ruby with plugins or extend_config in .standard.yml, and why can neither change Standard's own rules?
basics
~20 sList lint_roller plugin gems such as standard-rails under plugins:, or RuboCop YAML files under extend_config:. Configuration is first-in-wins: Standard's built-in plugins load first, so later plugins and files can add cops but never reconfigure ones already set.
Adopting RuboCop on a five-year-old Ruby codebase, how do you decide which departments and cops the team enforces, and how do you encode that in .rubocop.yml?
basics
~20 sEnforce what prevents bugs first: Lint and Security fail the build; Layout is autocorrected once; Style and Metrics are chosen deliberately. Encode it with department and cop Enabled, Severity, AllCops FailLevel and, for a strict opt-in list, DisabledByDefault.
Why does detekt's autoCorrect option leave most findings unfixed in a Gradle build?
basics
~20 sBecause autoCorrect only reaches rules that implement a correction. Most detekt rules describe a design problem with no mechanical fix — a long method or a magic number cannot be rewritten automatically — so they stay reported no matter how the flag is set.
Why is RuboCop slow when an editor or git hook runs it per file, and what do its --server mode and --lsp language server change?
basics
~20 sEach rubocop invocation spends much of its time loading RuboCop and its plugins. --server keeps a background process with everything loaded and forwards later commands to it; --lsp runs a long-lived language server that editors talk to directly.
Your team enforces a phpcs.xml.dist ruleset on every pull request; what can break when upgrading PHP_CodeSniffer from 3.x to 4.0?
basics
~20 sUpgrading to PHP_CodeSniffer 4.0 changes exit codes, the default standard (PEAR to PSR12) and output streams, removes the @codingStandardsIgnore annotations, some sniffs and the string array-property syntax, and renames several error codes, so check scripts, suppressions and the ruleset.
How do PHP CS Fixer's cache file and parallel runner speed up runs, and when can each cause trouble?
basics
~20 sPHP CS Fixer skips files whose content hash matches .php-cs-fixer.cache and reruns everything when the rules or tool version change, and since 3.94 it spreads files across worker processes by default; stale caches and constrained CI machines are the usual sources of trouble.
You are starting a new open-source Ruby gem that supports Ruby 3.2 and later: how would you set up Standard, and when would plain RuboCop be the better choice?
basics
~20 sPut standard in the Gemfile's development group, set ruby_version: 3.2 in .standard.yml, and make rake's default task run tests and standard. Choose plain RuboCop to tune cops, enforce Metrics, or use features newer than Standard's pinned RuboCop.
showing 31–46 of 46