Giter Site home page Giter Site logo

changing only some rules about credo HOT 8 CLOSED

rrrene avatar rrrene commented on May 8, 2024 3
changing only some rules

from credo.

Comments (8)

rrrene avatar rrrene commented on May 8, 2024 1

Hi there. Copypasta is currently the only option, but that behaviour will change soon. If sou have any suggestions/input on this it is more than welcome! 👍🏻

from credo.

manukall avatar manukall commented on May 8, 2024

I have the same question. I'd like to disable a rule without having to maintain the list of rules or forgetting to add a new rule when a new version is released.

from credo.

smeevil avatar smeevil commented on May 8, 2024

How about a config file fallback chain that will look for a .credo.exs file in the current project, if that is not found then it will look for one in the home dir ~/.credo.exs , and if that is not found it will just use the defaults.

We could then format the custom config file for example like :

%{
  configs: [
    name: "default",
    ignore_checks: [
      {Credo.Check.Readability.ModuleDoc},
      ...
    ],
    override_checks: [
      {Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 80},
      ...
    ]
  ]
}

as long as the custom config has no key 'checks' it will include all the checks as defined in the default config coming from credo, if it does have the key, it will naturally only use those checks. Basically we are using the default config, and then merge the settings from our custom config over it.

What do you think about this ?

from credo.

rrrene avatar rrrene commented on May 8, 2024

I could guess where you got the idea for this. 😉 Unfortunately, I am opposed to having multiple keys for this.

The way it will most probably work in v0.4.0 is that the list of checks will be merged with the default list. The checks in your .credo.exs are prioritized and if you want to deactivate individual checks you just pust {Credo.Check.CheckModule, false} in the config.

P.S. The "config fallback" you describe is already active in Credo since - I think - the initial release. You can put a .credo.exs in any parent directory.

from credo.

smeevil avatar smeevil commented on May 8, 2024

Yeah the false annotation would work.

Would I be correct in assuming that the config file will then only contain override rules ?
So by default it would run all checks with default settings, unless in you specify otherwise in the config file. For example if you have {Credo.Check.CheckModule, false}, {Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 80} It would disable the CheckModule, override the default settings of the MaxLineLength and run all other checks with the defaults ?

P.S. Good stuff with the config fallback :)

from credo.

rrrene avatar rrrene commented on May 8, 2024

Yepp, that's how I think it should work.

Everyone I talk to tells me they don't want to monitor if new checks get implemented and that their prime use case is customizing/disabling a few checks. Quote: "Nobody wants to run just three checks."

So I am leaning very much towards following that line of thinking with the next "bigger" release.

from credo.

smeevil avatar smeevil commented on May 8, 2024

Sounds good :)

Let me know if there is anything that I could help with.

from credo.

rrrene avatar rrrene commented on May 8, 2024

This was released as part of v0.4.0-beta1. Please report any further issues you might find.

from credo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.