Giter Site home page Giter Site logo

Consistency error in regex about credo HOT 5 CLOSED

rrrene avatar rrrene commented on May 8, 2024
Consistency error in regex

from credo.

Comments (5)

rrrene avatar rrrene commented on May 8, 2024

Thanks for the bug report! I added a test reproducing the issue and will try to fix as soon as I can 👍

from credo.

hojgr avatar hojgr commented on May 8, 2024

I thank you for your work for the community :)

from credo.

c-rack avatar c-rack commented on May 8, 2024

@rrrene I just looked at this issue and think it is best to just remove the regex before applying the checks. But this lead to the next problem: how to properly detect the end of the regex? Instead of trying to detect the end of the regex, I propose to just strip everything following the ~r prefix.

So I came up with a simple but working solution by inserting

    line = line |> String.replace(~r/\~r.*$/, "")

before this line:
https://github.com/rrrene/credo/blob/master/lib/credo/check/consistency/space_in_parentheses/with_space.ex#L19

Yes, it is far from being optimal and may remove too much code that could contain problems, but until we find a better solution it should work. What do you think?

from credo.

rrrene avatar rrrene commented on May 8, 2024

@hojgr I re-opened this issue since it is not fixed, yet.

@c-rack I agree something like that will be the way to go. There is also the Credo.Code.Sigils module, which was introduced to strip sigils from source code. That way we could at least remove the ~r sigils cleanly.

from credo.

rrrene avatar rrrene commented on May 8, 2024

@hojgr v0.3.3 contains a fix. Thx again for reporting! 👍

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.