Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Renato Marinho
    @renatomarinho
    This message was deleted
    John Vandenberg
    @jayvdb
    @renatomarinho pls stop spamming every room on gitter
    Evan Brodie
    @ecbrodie

    Hello rubofriends. Is there a way to disable an entire family/group/namespace of cops for a particular set of files?

    For example, in my project, I want to disable all "Metrics" cops for my tests, but keep them enabled for all other code. I could just disable each Metrics cop for the test files as the violations pop up, but I want to see if this functionality already exists or requires a new feature.

    Thanks

    Okay, the correct term was "department", according to the documentation. So, the "Metrics" department.

    Also, I think I just discovered that it is indeed already existing, I was able to just use Metrics:... in my YAML and it worked. Still, not entirely sure if this is the correct approach because I can't find this case mentioned in the docs.

    Simon
    @stoivo

    Hi

    We want to try follow 10 lines per method. I think is is a good rule.
    In most controllers(Rails) we have strong params and with more then 8 agrument is expands over 10 lines.
    I wonder if there is a way to tell rubocop to not check method length for methids with params in it?

    Dominic Sayers
    @dominicsayers
    @ecbrodie So something like this works?
    Metrics:
      Exclude:
        - test/**/*
    Simon
    @stoivo
    anyone?
    Mailo Světel
    @roolo
    @stoivo I don't think it can be based on content of method, but you can disable the rule for that particular method. I would rather split the something_params method or look for another way to slim it
    Simon
    @stoivo

    The think is that we want to write it like

      def file_params
        params
          .require(:file)
          .permit(
            :description, 
            :user_id, 
            :content_type, 
            :created_at, 
            :updated_at, 
            :unit_id, 
            :document_id, 
            :document_type, 
            :sort_id, 
            :is_deleted
          )
      end

    I know I could write it on one line but we want to have it like this.
    In generall we think to 10 lines method like is good. For some controllers we have more then 10 parameters and need more then 10 lines.

    Thomas Volkmar Worm
    @tvw
    What is a reasonable default for Metrics/AbcSize? As soon as a method contains a few conditions, rubocop starts complaining. In order to satisfy rubocop, I had to split a method into two methods, though the code belongs together and makes much more sense in one method.
    Also Metrics/LineLength: I think VT100s are absolutely history. My lines are most of the time below 80, but when using a logger, a line could be longer and splitting the line just to satisfy rubocop makes the code looking very poor.
    Thomas Thomassen
    @thomthom
    Hi all. I'm working on a RuboCop extension - to aid SketchUp developers using our Ruby API. I'm currently reviewing the severity property of the custom departments we are adding. I was wondering if there was some insight to what the various levels available means?
    I've seen the list in the code, and in the docs: https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md#severity
    But I'm curious to when to use what. In particular, is "error" supposed to be used only when RuboCop encounter an internal error processing?
    I've been using error for one department, this one have a set of cops that check for some hard requirement in order to get a SketchUp extension submitted to our Extension Warehouse (basically our app store for extensions to SketchUp)
    But is this severity level misleading?
    Found some older github issues where it seemed to be somewhat unclear exactly what severity should be applied to the different type of reporters: rubocop-hq/rubocop#633
    Steve Whittaker
    @swhitt
    P
    Casper Christensen
    @casperc91_gitlab

    Hi. I have tried to search in the docs and on the web for a Rubocop rule to use <= and < instead of > or >= in comparison, example:

    # bad
    a > 2
    3 >= b
    
    #good
    2 < a
    b <= 3
    4 < c && c <= 7

    Does anyone know if this exist or not? Can't seem to find it.

    andre francois
    @francoisa
    I have installed rubocop 0.62.0 in my rails application, but when I run "bundle exec rake new_cop[dept/name]"
    I get the error : "Don't know how to build task 'new_cop'"
    How do I create a new cop?
    Tejas Bubane
    @tejasbubane
    @francoisa That rake task is for running inside the rubocop project directory itself. For contributing new cop.
    Brandon Weaver
    @baweaver

    Bit of an out there idea I'd be interested in a sanity check on. Javascript has the idea of codemods, I kinda want to try and make the same thing in Ruby. Rubocop already has a lot of work done on top of parser, including the NodePattern syntax and autocorrect capabilities.

    Is there a possibility of generalizing the autocorrect capability into a code rewrite gem?

    This gem does some of that already - https://github.com/jonatas/fast
    Well, rather is there interest in doing that? I'd be willing to pitch in on it if so, but I'd rather not jump on an idea that's either already been done or isn't of interest to the contributors
    MrAtheist
    @MrAtheist
    Hey all, would someone be able to address this issue for me? rubocop-hq/rubocop#6567 For me specifically the exclude in Allcops doesnt work at all. Wondering if it's the inheritance thats messing it up.
    Oppen
    @Oppen
    Hi, I have a possibly dumb question.
    I've seen in the changelog people refer to their PR. How can I have the PR address before sending it?
    I mean, I'm working in my changeset, I then upload it to a branch on my fork and create a PR, but then I can't go back and change it to use the proper id afterwards.
    (I could in a different commit, after creating the PR, but I've seen it done in a single one)
    John Vandenberg
    @jayvdb
    @Oppen after you create the PR, you can add another commit to your branch and it will be included in the PR. You can also 'amend' (replace) the initial commit
    Oppen
    @Oppen
    OK. I thought of amend, but that always carried weird consequences when I forced pushed.
    Thanks.
    Oppen
    @Oppen
    Hi all. I'm working in a performance related cop. Should I send it to rubocop, rubocop-performance or both?
    Simon
    @stoivo
    I have a open PR rubocop-hq/rubocop#6649, Could someone take a look at it and give me some feedback
    Lewis Jones
    @LewisARJones_twitter
    Hi, I use Rubocop to write custom cops within my companies code bases to enforce our domain and help aid big refactors. I've got blocked trying to write cops that check if methods are called on instances of our domain object. Basically ruby classes we have created.
    For example I want to write a cop that creates an offence if anyone sends the method expiry_date to and instance of Quote object object.
    Can anyone point in the direction of an example of how to write a cop that can check the class of the object getting the method sent to it?
    Thomas Thomassen
    @thomthom
    @LewisARJones_twitter The dynamic nature of Ruby makes this hard. I've tried to do something similar for rubocop-sketchup - but I found no good way to do so. In some cases I've scanned the parent scope to find the initialisation of the instance. But the moment the instance is passed on to other methods it gets really difficult to track. In the end I fell back on doing simple naive checks like mentioned. Or make educated guesses on variable names.
    You can see this being a challenge even for IDEs like RubyMine or VSCode with Ruby+Solargraph extensions. They tend to make use of YARD to pick up types from doc comments to aid the static analysic. But they also have to analyse the whole project to have chance. If you have good YARD comments you could try to leverage that in your custom cops.
    Jônatas Davi Paganini
    @jonatas
    @LewisARJones_twitter any reason to not deprecate the usage of expiry_date in the Quote object? because it seems more reasonable than try to create a linter for it. Make the interface fail or warn developers about it. When they run tests they will know the api is no longer going to support it.
    Lewis Jones
    @LewisARJones_twitter
    Thanks for your help @jonatas and @thomthom
    Mailo Světel
    @roolo
    Hey guys, I just discovered AllCops are being rewritten by children configs, what is the right way to do it?
    https://gitlab.com/lipoqil/rubocop-mailo/blob/459031ee5e101aa471dca90b202836f8d37025ca/rubocop.yaml#L1-7 If I use AllCops - Exclude in file which inherits from this one, the configs from gem are ignored 🥺
    Rubocop 0.65.0
    Philipp Hansch
    @phansch
    Hi, is there some way to write a cop that detects usage of :[] on Hashes and suggest fetch instead? Specifically, how could I limit this to only work on Hash?
    I suppose this is more difficult as I thought because of Ruby's dynamic nature..
    i.e, I'm currently getting false positives on Dir[pat], some_array[x], etc
    Jonas Arvidsson
    @jonas054
    @phansch The short answer is "No". You'd have to add functionality in RuboCop to guess the type of values, similar to what "intellisense"/auto-completion does in IDEs.
    Colin Swenson-Healey
    @chozandrias76
    Has anyone else recently updated rubocop, added the rubocop-performance gem and found that rubocop no longer inspects any of the files you had it inspecting before?
    It is inspecting only 2 files now when I run rubocop and I don't know which those are or why anything has changed
    Lee-Jon
    @lee-jon
    Hey @chozandrias76 did you solve the issue? I have the same issue jumping from 47 -> 75
    Lee-Jon
    @lee-jon
    I solved it by deleting the yml file and rewriting it line by line.