Coder Social home page Coder Social logo

Comments (6)

mhanberg avatar mhanberg commented on August 29, 2024

I can submit a patch to change the behavior if this seems appropriate.

from credo.

rrrene avatar rrrene commented on August 29, 2024

Understood. The only thing that is important is that we can not compile or execute code from the analyzed project in Credo, because it is a static analysis tool that "just looks at the code". We might already have violated that rule with the check's current implementation, which does not work for situations where --working-dir is set to some other (not loaded) Mix project.

Maybe we should just provide an example to configure the check (as proposed by @milmazz at the start of his original PR):

# uncomment an modify this to your needs:
{Credo.Check.Warning.IgnoredLoggerMetadata, [metadata_keys: "config/prod.exs" |> Config.Reader.read!() |> get_in([:logger, :console, :metadata])]},

we can do this because .credo.exs is just a regular Elixir script and if the user leverages this fact to read the projectΒ΄s actual config and provides that as a parameter to the check, then we're fine.

WDYT?

from credo.

mhanberg avatar mhanberg commented on August 29, 2024

I upgraded to 1.7 today and I ended up just disabling this check.

from credo.

angelikatyborska avatar angelikatyborska commented on August 29, 2024

Maybe we should just provide an example to configure the check

That would be a good improvement. In the check's explanation? I had to configure the check in my project to make it work too, for the same reason as is the topic of this issue πŸ™‚

In case anyone is reading this thread half-asleep, rrrene's example needs to be modified to work:

{Credo.Check.Warning.IgnoredLoggerMetadata, [metadata_keys: "config/prod.exs" |> Config.Reader.read!() |> get_in([:logger, :console, :metadata])]},

First, the check's module name is different. Second, if you hit this problem because you don't have the console backend in production, you need to pass the name of your actual logger backend. In my case it's :file_log. This config worked for me:

  {Credo.Check.Warning.MissedMetadataKeyInLoggerConfig,
   [
     metadata_keys:
       "config/prod.exs" |> Config.Reader.read!() |> get_in([:logger, :file_log, :metadata])
   ]}

from credo.

rrrene avatar rrrene commented on August 29, 2024

This is part of 1.7.2-rc.3 πŸ‘

from credo.

rrrene avatar rrrene commented on August 29, 2024

This is part of Credo 1.7.2. πŸ‘

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.