Skip to content

Enable ameba in this repo #14608

Open
@straight-shoota

Description

@straight-shoota

https://github.com/crystal-ameba/ameba is a great code analysis tool for Crystal. It has some limitations because it only operates on the syntax level.
We've had some improvements based on ameba's suggestions in the past (#12685, #12730, #12637, #12648 and more).

It should be easy to set up ameba to run automatically on this repo for continuous monitoring of new code submissions.
I think there's a huge gain from ensuring we avoid a wide range of simple errors that ameba can detect.

The code base is pretty huge and there are a lot of violations of ameba rules. But that shouldn't be a problem. Ameba can automatically analyize the current state and add exclusions for existing linter issues. That would let us start using ameba on new code additions already before fixing everything in the existing code.

We could also consider disabling some default rules entirely and re-evaluate in the future.
I see two reasons for this:

  • Disable frequently violated rules for efficiency. For example, Lint/NotNil, Naming/BlockParameterName, Naming/VariableNames each report over 400 problems. It's going to be hard to fix them all in the short run.
  • Some of the default rules may be a bit too opinionated.

So I'd suggest the following plan:

  1. Add a basic .ameba.yml config with exclusions for all current problems (via ameba --gen-config).
  2. Discuss which rules we may want to disable entirely (permanently or temporarily). (or maybe the other way around: start with a blank slate and discuss which rules we want to enable?)
  3. Add an ameba job to the CI config to ensure we catch problems in code submissions
  4. Start fixing the reported problems, one rule at a time. Starting with the low-hanging fruits which ameba can autofix (ameba --fix).

Any other ideas?
/cc @Sija @veelenga

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions