AyuntamientoMadrid/participacion

View on GitHub
spec/models/sdg/local_target_spec.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

    it "can be compared against global targets" do
      lesser_target = build(:sdg_target, code: "10.A", goal: SDG::Goal[10])
      greater_target = build(:sdg_target, code: "11.1", goal: SDG::Goal[11])

      expect(local_target).to be > lesser_target
Severity: Minor
Found in spec/models/sdg/local_target_spec.rb and 1 other location - About 40 mins to fix
spec/models/sdg/goal_spec.rb on lines 35..40

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 38.

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 6 locations. Consider refactoring.
Open

    it "can be compared against goals" do
      lesser_goal = build(:sdg_goal, code: "10")
      greater_goal = build(:sdg_goal, code: "11")

      expect(local_target).to be > lesser_goal
Severity: Major
Found in spec/models/sdg/local_target_spec.rb and 5 other locations - About 20 mins to fix
spec/models/sdg/goal_spec.rb on lines 43..48
spec/models/sdg/local_target_spec.rb on lines 82..87
spec/models/sdg/local_target_spec.rb on lines 90..95
spec/models/sdg/target_spec.rb on lines 96..101
spec/models/sdg/target_spec.rb on lines 121..126

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 28.

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 6 locations. Consider refactoring.
Open

    it "compares using the target first" do
      lesser_local_target = create(:sdg_local_target, code: "10.A.1")
      greater_local_target = create(:sdg_local_target, code: "11.1.1")

      expect(local_target).to be > lesser_local_target
Severity: Major
Found in spec/models/sdg/local_target_spec.rb and 5 other locations - About 20 mins to fix
spec/models/sdg/goal_spec.rb on lines 43..48
spec/models/sdg/local_target_spec.rb on lines 90..95
spec/models/sdg/local_target_spec.rb on lines 106..111
spec/models/sdg/target_spec.rb on lines 96..101
spec/models/sdg/target_spec.rb on lines 121..126

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 28.

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 6 locations. Consider refactoring.
Open

    it "compares using the local target code when the target is the same" do
      lesser_local_target = create(:sdg_local_target, code: "10.B.9")
      greater_local_target = create(:sdg_local_target, code: "10.B.11")

      expect(local_target).to be > lesser_local_target
Severity: Major
Found in spec/models/sdg/local_target_spec.rb and 5 other locations - About 20 mins to fix
spec/models/sdg/goal_spec.rb on lines 43..48
spec/models/sdg/local_target_spec.rb on lines 82..87
spec/models/sdg/local_target_spec.rb on lines 106..111
spec/models/sdg/target_spec.rb on lines 96..101
spec/models/sdg/target_spec.rb on lines 121..126

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 28.

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

  it "is not valid when code does not include associated target code" do
    local_target = build(:sdg_local_target, code: "1.6.1", target: SDG::Target[1.1])

    expect(local_target).not_to be_valid
    expect(local_target.errors.full_messages).to include "Code must start with the same " \
Severity: Minor
Found in spec/models/sdg/local_target_spec.rb and 1 other location - About 15 mins to fix
spec/models/sdg/local_target_spec.rb on lines 33..37

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 26.

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

  it "is not valid when local target code part is not a number" do
    local_target = build(:sdg_local_target, code: "1.1.A", target: SDG::Target[1.1])

    expect(local_target).not_to be_valid
    expect(local_target.errors.full_messages).to include "Code must start with the same " \
Severity: Minor
Found in spec/models/sdg/local_target_spec.rb and 1 other location - About 15 mins to fix
spec/models/sdg/local_target_spec.rb on lines 24..28

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 26.

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