by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Michael Hagar
    @mehagar

    Hi, I believe I found a bug that has possibly been fixed in a newer version of Rubocop. In version 0.57.2, this code:

    time_period = updated_during ? updated_during : 2.days.ago..Time.now

    is autocorrected to

    time_period = updated_during || 2.days.ago..Time.now

    However, that’s incorrect if updated_during is not nil, because || has a higher precedence than .., whereas ? has a lower precedence than ...

    Ankit Kumar
    @anks333
    how to configure rubocop in vs code, tried installing ruby-rubocop but throwing error env: jruby_executable_hooks: No such file or directory
    can someone help me to configure rubocop in vscode
    Jônatas Davi Paganini
    @jonatas

    Hello friends! Is there any research or ongoing mechanism to allow us to use RuboCop combining autocorrect with user input confirmation?

    I'm asking because today a friend shared a script (https://gist.github.com/jaimerson/57847f25191f58018af06c1c1ea0e4f6) that autocorrects subject names from RSpec/NamedSubject and gives the opportunity to fix it ongoing or accept the suggestions. While cleaning up offenses it would speed up a lot the flow and we could have a default and allow people to edit it if they want through the interactive mode.

    It would also allow us to interactive fix cops that doesn't have autocorrect implementation because of some the dependency of the user input.

    paulgureghian
    @paulgureghian_gitlab
    hi
    paulgureghian
    @paulgureghian_gitlab

    Trying to find the Rubocop yml file. I looked in the .gem and .rvm folders.

    https://imgur.com/a/Hf2htqm

    Andrew Jorgensen
    @ajorgensen
    I have a rubocop question, hopefully this is the right place. I have a custom cop that compares class names to make sure there are no duplicates. The issue that i have is the class names are stored in a class level variable that gets cached in rubocop-daemon between runs so the first run is successful but the second one detects a duplicate class. Is there anything in rubocop that would allow me to clear that cache after the run or a run identifier I can make sure that names are compared within the same run and not across runs?
    The only other way i can think to do it without a before_run, after_run hook or an identifier is to time out the cache after a certain period of time
    Andrew Jorgensen
    @ajorgensen
    It looks like the cops are created new for each source which makes cross file comparison difficult
    Andrew Jorgensen
    @ajorgensen
    sorry the above was actually more of a consequence of using rubocop-daemon rather than rubocop itself
    i was able to work around it by finding the Rubocop::Runner instance and using its object_id as a unique run identifier and then invalidating the cache if the run id is different. This allows us to detect different runs and invalidate the cache. I realize that comparing across all files is probably not a typical use case for Rubocop but in our setup (lots of rails engines) it was important to make sure there were not two classes named the same
    Brandon Weaver
    @baweaver

    @marcandre RE: https://github.com/rubocop-hq/rubocop/pull/7868#issuecomment-642392984

    May not quite be the right place for it but does unlock a lot of interesting potential for really succinct corrections

    Utkarsh Gupta
    @utkarsh2102
    Hiya
    I had a quick question that I am unable to figure out
    My PATTERN can't parse the second call to git, that is, spec.executables.
    Utkarsh Gupta
    @utkarsh2102
    Any clue what am I doing wrong? Or how can I go about fixing this?
    Utkarsh Gupta
    @utkarsh2102
    CC: @marcandre, guess you'd know^ :)
    Marc-André Lafortune
    @marcandre
    @utkarsh2102 The descend operator only looks for the first descendant it encounters. You'll have to split your pattern in two
    Marc-André Lafortune
    @marcandre
    We should consider something do select all that match instead of any that match though.
    Utkarsh Gupta
    @utkarsh2102
    @marcandre, ah, didn't know this, thanks :)
    If it's not much to ask, could you also help me figure out how to do this?
    Marc-André Lafortune
    @marcandre
    I'd first look for the right module, then use def_node_search to find what you're looking for. HTH
    Utkarsh Gupta
    @utkarsh2102
    Gives me a starting point but I'm still unsure. Also, thanks :)
    Daniel Vandersluis
    @dvandersluis
    Is there a recommended way to test a def_node_matcher? Anyone have an example?
    Daniel Vandersluis
    @dvandersluis
    Never mind, I think I figured it out. When a cop is instantiated the node matchers are available publicly so I can just use that in my expectation
    Utkarsh Gupta
    @utkarsh2102
    Hi @marcandre,
    With your new API changes (wrt v1 upgrade notes ), I am not entirely sure which part is broken on my Cop (with RuboCop v0.87.x) :sweat_smile:
    Can you please do a quick PR review of utkarsh2102/rubocop-packaging#4 (whenever you're free!) and suggest the changes? :smile:
    Marc-André Lafortune
    @marcandre
    Sorry @utkarsh2102 , nothing jumps at me as problematic, I'm not sure why you are seeing a difference in behavior
    Please let me know what you find...
    Utkarsh Gupta
    @utkarsh2102
    Thank you, @marcandre, for your review (you the best! :heart:).
    When I run git bisect, I get rubocop-hq/rubocop@f8813e7 from where things started to fail for me :/
    I am still not sure what's wrong, I am trying to figure out and shall let you know in case I get something.
    But really, thank you for your review! It does help me in narrowing some things down!
    (and in case something strikes you about this problem, let me know \o/)
    Marc-André Lafortune
    @marcandre
    How can I reproduce your issue exactly?
    Utkarsh Gupta
    @utkarsh2102
    From rubocop's master, I am running this: git bisect start master v0.86.0 && git bisect run sh -c "cd /home/utkarsh/github/rubocop-packaging; RUBYLIB=/home/utkarsh/github/rubocop/lib rspec" && git bisect reset

    How can I reproduce your issue exactly?

    Or you can just run: rspec on rubocop-packaging with rubocop v0.86 and v0.87.
    With v0.86, the tests pass. With v0.87, the tests fail :disappointed:

    Marc-André Lafortune
    @marcandre
    Ok, let me check
    Utkarsh Gupta
    @utkarsh2102
    Thank you! \o/
    Phil Pirozhkov
    @pirj

    Hey!
    Two quick questions:

    Is 0.89 going to be released soon? My hands are itching to merge the PR (in rubocop-rspec) fixing offences raised by newly introduced cops.

    WDYT of bumping the version in version.rb to the next patch version? We have an edge-rubocop CI job, and it fetches RuboCop from master. It's somewhat confusing to see Using rubocop 0.88.0 from https://github.com/rubocop-hq/rubocop.git (at master@ca9483a) and failures from cops that didn't exist in 0.88.0.

    Marc-André Lafortune
    @marcandre
    👍 and 👍. Or would '0.88.0.dev' be good sufficient?
    I'd like a release of rubocop-ast too.
    Phil Pirozhkov
    @pirj
    Yes! '0.88.0-next' or what SemVer suggests.
    Thanks!
    Marc-André Lafortune
    @marcandre
    I don't know if @bbatsov is on gitter much...
    I just made a release of rubocop-ast.
    Daniel Vandersluis
    @dvandersluis
    is it possible to collect captures from def_search_node?
    Marc-André Lafortune
    @marcandre
    Yes, no problem; they'll be from the first match, if any...
    Now that we have the descend operator "", there's less need fordef_search_node`
    Daniel Vandersluis
    @dvandersluis
    How do I access the captures?
    Marc-André Lafortune
    @marcandre
    Actually I was wrong, sorry. The doc says "[If it does not end with '?'], it yield all descendants which match.". So my_node_search do |first_capture, second_capture| ...