HuntersKeepers icon indicating copy to clipboard operation
HuntersKeepers copied to clipboard

Remove Duplication Check in codeclimate.yml

Open ChaelCodes opened this issue 4 years ago • 0 comments

Describe the Feature

Is your feature request related to a problem? Please describe. HuntersKeepers is not prone to merging duplicated logic, however, we frequently use scaffolds to generate our controllers, and these scaffolded controllers often trip up duplication checks. Let's turn off the similar-code duplication check from code climate.

Additional context DRY or Don't Repeat Yourself refers to business logic, not lines of code as most think. Duplication makes it harder to change the logic in your system, because you have to change it in multiple places. Scaffolded controllers have a lot of similar code around format, like:

  def create
    @gear = Gear.new(gear_params)

    respond_to do |format|
      if @gear.save
        format.html { redirect_to @gear, notice: 'Gear was successfully created.' }
        format.json { render :show, status: :created, location: @gear }
      else
        format.html { render :new }
        format.json { render json: @gear.errors, status: :unprocessable_entity }
      end
    end
  end

Extracting the duplication of HTML and json into an ApplicationController does not make this method easier to understand or change. Therefore we don't care about the duplication in controllers. Because we're not fighting a lot of duplication in the app, but we are tripping the check regularly under this false circumstance, it's easier to remove the check and check for duplication manually.

Describe the Technical Implementation of the Solution

Solution Set duplication to disabled in codeclimate.yml

References Codeclimate's docs on configuring duplication CodeClimate's docs on configuring

ChaelCodes avatar Jan 31 '21 14:01 ChaelCodes