codeclimate / codeclimate-duplication

Code Climate engine for code duplication analysis
http://codeclimate.com
MIT License
113 stars 24 forks source link

Allow setting separate language specific mass thresholds for identical and similar code #326

Open rdimartino opened 6 years ago

rdimartino commented 6 years ago

I can set separate check mass thresholds with

checks:
  identical-code:
    config:
      threshold: 25
  similar-code:
    config:
      threshold: 50

but those aren't language specific.

I can set a language-specific mass threshold with

plugins:
  duplication:
    config:
      languages:
        javascript:
          mass_threshold: 50

but that sets the threshold for both identical and similar code.

I want to be able to do something like

plugins:
  duplication:
    config:
      languages:
        javascript:
          identical-code:
            mass_threshold: 25
          similar-code:
            mass_threshold: 50
kevinleturc commented 6 years ago

👍

efueger commented 6 years ago

Hi @kevinleturc and @rdimartino - thanks for the suggestion. Although I don't have an ETA, this is something that we're looking at adding.

Can you tell me a little bit more about your use case?

rdimartino commented 6 years ago

@efueger We're using a Rails backend with a React frontend. We were getting some false positives when using some of our more template-like React components that have a little bit more boilerplate but can't really be abstracted further.

As a work around for this we currently doing something like:

checks:
  identical-code:
    config:
      threshold: 35
...
plugins:
  duplication:
    enabled: true
    config:
      languages:
        javascript:
          mass_threshold: 75

but this is obviously not ideal.

hiattp commented 5 years ago

We're in the same boat, Rails backend + React frontend. In particular React has a lot of structure repetition (considered best practice afaik) like PropTypes (see #89).

zharikovpro commented 4 years ago

Same for us. Really want to decrease identical-code threshold only for the Javascript, as we use Ember. Works fine for the backend part on Rails.

ygnessin commented 4 years ago

+1 for this. Our use-case is an android project that is partially java and partially kotlin. Thanks!

RichStone commented 3 years ago

+1, we have a similar situation where frontend technologies should have a different threshold than backend. Is this still being considered?

devProdigy commented 1 year ago

+1 it'd be very useful. We need to separate frontend from backend as well. I wonder if there's a way to do so, maybe create separate .codeclimate.yml config files in separate folders?