orange-cloudfoundry/cf-ops-automation

View on GitHub
lib/coa/utils/concourse/concourse.rb

Summary

Maintainability
A
50 mins
Test Coverage
D
66%

Coa::Utils::Concourse::Concourse takes parameters ['name', 'team'] to 4 methods
Open

        def set_pipeline(name:, options:, team: "main")
          Coa::Utils::Concourse::Pipeline.
            new(name: name, team: team, concourse: self).
            set(options)
        end
Severity: Minor
Found in lib/coa/utils/concourse/concourse.rb by reek

In general, a Data Clump occurs when the same two or three items frequently appear together in classes and parameter lists, or when a group of instance variable names start or end with similar substrings.

The recurrence of the items often means there is duplicate code spread around to handle them. There may be an abstraction missing from the code, making the system harder to understand.

Example

Given

class Dummy
  def x(y1,y2); end
  def y(y1,y2); end
  def z(y1,y2); end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [2, 3, 4]:Dummy takes parameters [y1, y2] to 3 methods (DataClump)

A possible way to fix this problem (quoting from Martin Fowler):

The first step is to replace data clumps with objects and use the objects whenever you see them. An immediate benefit is that you'll shrink some parameter lists. The interesting stuff happens as you begin to look for behavior to move into the new objects.

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        def pause_job(name:, pipeline_name:, team: "main")
          pipeline = Coa::Utils::Concourse::Pipeline.
            new(name: pipeline_name, team: team, concourse: self)
          Coa::Utils::Concourse::Job.new(name: name, pipeline: pipeline).pause
Severity: Minor
Found in lib/coa/utils/concourse/concourse.rb and 1 other location - About 25 mins to fix
lib/coa/utils/concourse/concourse.rb on lines 32..35

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

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

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

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.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        def trigger_job(name:, pipeline_name:, team: "main")
          pipeline = Coa::Utils::Concourse::Pipeline.
            new(name: pipeline_name, team: team, concourse: self)
          Coa::Utils::Concourse::Job.new(name: name, pipeline: pipeline).trigger
Severity: Minor
Found in lib/coa/utils/concourse/concourse.rb and 1 other location - About 25 mins to fix
lib/coa/utils/concourse/concourse.rb on lines 38..41

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

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

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

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.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

There are no issues that match your filters.

Category
Status