Giter Site home page Giter Site logo

efueger / codeclimate-duplication Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codeclimate/codeclimate-duplication

0.0 2.0 0.0 320 KB

Code Climate engine for code duplication analysis

Home Page: http://codeclimate.com

License: MIT License

Ruby 93.63% Makefile 0.34% HTML 2.94% JavaScript 1.56% Python 1.53%

codeclimate-duplication's Introduction

codeclimate-duplication

Code Climate

codeclimate-duplication is an engine that wraps flay and supports Ruby, Python, JavaScript, and PHP. You can run it on the command line using the Code Climate CLI or on our hosted analysis platform.

What is duplication?

The duplication engine's algorithm can be surprising, but it's actually very simple. We have a docs page explaining the algorithm.

Installation

  1. Install the Code Climate CLI, if you haven't already.
  2. Run codeclimate engines:enable duplication. This command installs the engine and enables it in your .codeclimate.yml file.
  3. You're ready to analyze! cd into your project's folder and run codeclimate analyze.

Configuring

Languages

By enabling the duplication engine with the Code Climate CLI, all supported languages are configured by default, but we recommend adjusting this configuration to enable only the languages you care about. If you have a project with Ruby and JavaScript files, you might want the following configuration:

engines:
  duplication:
    enabled: true
    config:
      languages:
      - ruby
      - javascript

This will tell the duplication engine to analyze Ruby and JavaScript files.

Mass Threshold

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The mass threshold configuration represents the minimum "mass" a code block must have to be analyzed for duplication. If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

To adjust this setting, add a mass_threshold key with your preferred value for an enabled language:

engines:
  duplication:
    enabled: true
    config:
      languages:
        ruby:
          mass_threshold: 20
        javascript:

Note that you have the update the YAML structure under the languages key to the Hash type to support extra configuration.

Count Threshold

By default, the duplication engine will report code that has been duplicated in just two locations. You can be less strict by only raising a warning if code is duplicated in three or more locations only. To adjust this setting, add a count_threshold key to your config. For instance, to use the default mass_threshold for ruby, but to enforce the Rule of Three, you could use this configuration:

engines:
  duplication:
    enabled: true
    config:
      languages:
        ruby:
          count_threshold: 3

You can also change the default count_threshold for all languages:

engines:
  duplication:
    enabled: true
    count_threshold: 3

Excluding files and directories

As with any other Code Climate engine, you can exclude certain files or directories from being analyzed. For more information, see Exclude paths for specific engines in our documentation.

engines:
  duplication:
    exclude_paths:
    - examples/

codeclimate-duplication's People

Contributors

wfleming avatar blakewilliams avatar dblandin avatar pbrisbin avatar jpignata avatar maxjacobson avatar gdiggs avatar mrb avatar noahd1 avatar brynary avatar devvmh avatar mange avatar mxie avatar

Watchers

James Cloos avatar  avatar

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.