mhuggins/ruby-measurement

View on GitHub

Showing 61 of 61 total issues

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

Measurement.define(:'in²') do |unit|
  unit.alias :in2, :'in*in', :'sq in', :'square inch', :'square inches'
  unit.convert_to(:mi2) { |value| value / 4_014_489_600.0 }
  unit.convert_to(:fur2) { |value| value / 62_726_400.0 }
  unit.convert_to(:ch2) { |value| value / 627_264.0 }
Severity: Major
Found in lib/ruby-measurement/definitions/us_customary/area.rb and 5 other locations - About 1 hr to fix
lib/ruby-measurement/definitions/us_customary/area.rb on lines 3..9
lib/ruby-measurement/definitions/us_customary/area.rb on lines 12..18
lib/ruby-measurement/definitions/us_customary/area.rb on lines 21..27
lib/ruby-measurement/definitions/us_customary/area.rb on lines 30..36
lib/ruby-measurement/definitions/us_customary/area.rb on lines 39..45

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

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

Measurement.define(:'mi²') do |unit|
  unit.alias :mi2, :'mi*mi', :'sq mi', :'square mile', :'square miles'
  unit.convert_to(:fur2) { |value| value * 64.0 }
  unit.convert_to(:ch2) { |value| value * 6_400.0 }
  unit.convert_to(:yd2) { |value| value * 3_097_600.0 }
Severity: Major
Found in lib/ruby-measurement/definitions/us_customary/area.rb and 5 other locations - About 1 hr to fix
lib/ruby-measurement/definitions/us_customary/area.rb on lines 12..18
lib/ruby-measurement/definitions/us_customary/area.rb on lines 21..27
lib/ruby-measurement/definitions/us_customary/area.rb on lines 30..36
lib/ruby-measurement/definitions/us_customary/area.rb on lines 39..45
lib/ruby-measurement/definitions/us_customary/area.rb on lines 48..54

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

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

Measurement.define(:'ch²') do |unit|
  unit.alias :ch2, :'ch*ch', :'sq ch', :'square chain', :'square chains'
  unit.convert_to(:mi2) { |value| value / 6_400.0 }
  unit.convert_to(:fur2) { |value| value / 100.0 }
  unit.convert_to(:yd2) { |value| value * 484.0 }
Severity: Major
Found in lib/ruby-measurement/definitions/us_customary/area.rb and 5 other locations - About 1 hr to fix
lib/ruby-measurement/definitions/us_customary/area.rb on lines 3..9
lib/ruby-measurement/definitions/us_customary/area.rb on lines 12..18
lib/ruby-measurement/definitions/us_customary/area.rb on lines 30..36
lib/ruby-measurement/definitions/us_customary/area.rb on lines 39..45
lib/ruby-measurement/definitions/us_customary/area.rb on lines 48..54

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

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

Measurement.define(:'ft²') do |unit|
  unit.alias :ft2, :'ft*ft', :'sq ft', :'square foot', :'square feet'
  unit.convert_to(:mi2) { |value| value / 27_878_400.0 }
  unit.convert_to(:fur2) { |value| value / 435_600.0 }
  unit.convert_to(:ch2) { |value| value / 4_356.0 }
Severity: Major
Found in lib/ruby-measurement/definitions/us_customary/area.rb and 5 other locations - About 1 hr to fix
lib/ruby-measurement/definitions/us_customary/area.rb on lines 3..9
lib/ruby-measurement/definitions/us_customary/area.rb on lines 12..18
lib/ruby-measurement/definitions/us_customary/area.rb on lines 21..27
lib/ruby-measurement/definitions/us_customary/area.rb on lines 30..36
lib/ruby-measurement/definitions/us_customary/area.rb on lines 48..54

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

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

Measurement.define(:lb) do |unit|
  unit.alias :lbs, :pound, :pounds
  unit.convert_to(:ton) { |value| value / 2000.0 }
  unit.convert_to(:cwt) { |value| value / 100.0 }
  unit.convert_to(:oz) { |value| value * 16.0 }
Severity: Major
Found in lib/ruby-measurement/definitions/us_customary/weight.rb and 1 other location - About 1 hr to fix
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 3..9

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

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

Measurement.define(:ton) do |unit|
  unit.alias :'short ton', :'short tons', :tons
  unit.convert_to(:cwt) { |value| value * 20.0 }
  unit.convert_to(:lb) { |value| value * 2_000.0 }
  unit.convert_to(:oz) { |value| value * 32_000.0 }
Severity: Major
Found in lib/ruby-measurement/definitions/us_customary/weight.rb and 1 other location - About 1 hr to fix
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 21..27

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

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

Measurement.define(:dr) do |unit|
  unit.alias :dram, :drams
  unit.convert_to(:ton) { |value| value / 512_000.0 }
  unit.convert_to(:cwt) { |value| value / 25_600.0 }
  unit.convert_to(:lb) { |value| value / 256.0 }
Severity: Major
Found in lib/ruby-measurement/definitions/us_customary/weight.rb and 3 other locations - About 1 hr to fix
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 12..18
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 30..36
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 48..54

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

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

Measurement.define(:gr) do |unit|
  unit.alias :grain, :grains
  unit.convert_to(:ton) { |value| value / 14_000_000.0 }
  unit.convert_to(:cwt) { |value| value / 700_000.0 }
  unit.convert_to(:lb) { |value| value / 7000.0 }
Severity: Major
Found in lib/ruby-measurement/definitions/us_customary/weight.rb and 3 other locations - About 1 hr to fix
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 12..18
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 30..36
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 39..45

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

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

Measurement.define(:oz) do |unit|
  unit.alias :ounce, :ounces
  unit.convert_to(:ton) { |value| value / 32_000.0 }
  unit.convert_to(:cwt) { |value| value / 1_600.0 }
  unit.convert_to(:lb) { |value| value / 16.0 }
Severity: Major
Found in lib/ruby-measurement/definitions/us_customary/weight.rb and 3 other locations - About 1 hr to fix
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 12..18
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 39..45
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 48..54

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

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

Measurement.define(:cwt) do |unit|
  unit.alias :hundredweight, :hundredweights
  unit.convert_to(:ton) { |value| value / 20.0 }
  unit.convert_to(:lb) { |value| value * 100.0 }
  unit.convert_to(:oz) { |value| value * 1_600.0 }
Severity: Major
Found in lib/ruby-measurement/definitions/us_customary/weight.rb and 3 other locations - About 1 hr to fix
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 30..36
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 39..45
lib/ruby-measurement/definitions/us_customary/weight.rb on lines 48..54

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

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

Measurement.define(:'km²') do |unit|
  unit.alias :km2, :'km^2', :'km*km', :'sq km', :'square kilometer', :'square kilometers'
  unit.convert_to(:ha) { |value| value * 100.0 }
  unit.convert_to(:a) { |value| value * 10_000.0 }
  unit.convert_to(:m2) { |value| value * 1_000_000.0 }
Severity: Major
Found in lib/ruby-measurement/definitions/metric/area.rb and 2 other locations - About 55 mins to fix
lib/ruby-measurement/definitions/metric/area.rb on lines 27..32
lib/ruby-measurement/definitions/metric/area.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 46.

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

Measurement.define(:'m²') do |unit|
  unit.alias :m2, :'m^2', :'m*m', :'sq m', :'square meter', :'square meters'
  unit.convert_to(:km2) { |value| value / 1_000_000.0 }
  unit.convert_to(:ha) { |value| value / 10_000.0 }
  unit.convert_to(:a) { |value| value / 100 }
Severity: Major
Found in lib/ruby-measurement/definitions/metric/area.rb and 2 other locations - About 55 mins to fix
lib/ruby-measurement/definitions/metric/area.rb on lines 3..8
lib/ruby-measurement/definitions/metric/area.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 46.

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

Measurement.define(:'cm²') do |unit|
  unit.alias :cm2, :'cm^2', :'cm*cm', :'sq cm', :'square centimeter', :'square centimeters'
  unit.convert_to(:km2) { |value| value / 10_000_000_000.0 }
  unit.convert_to(:ha) { |value| value / 100_000_000.0 }
  unit.convert_to(:a) { |value| value / 1_000_000.0 }
Severity: Major
Found in lib/ruby-measurement/definitions/metric/area.rb and 2 other locations - About 55 mins to fix
lib/ruby-measurement/definitions/metric/area.rb on lines 3..8
lib/ruby-measurement/definitions/metric/area.rb on lines 27..32

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

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

Measurement.define(:a) do |unit|
  unit.alias :are, :ares
  unit.convert_to(:km2) { |value| value / 10_000.0 }
  unit.convert_to(:ha) { |value| value / 100.0 }
  unit.convert_to(:m2) { |value| value * 100.0 }
Severity: Minor
Found in lib/ruby-measurement/definitions/metric/area.rb and 1 other location - About 50 mins to fix
lib/ruby-measurement/definitions/metric/area.rb on lines 11..16

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

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

Measurement.define(:ha) do |unit|
  unit.alias :hectare, :hectares
  unit.convert_to(:km2) { |value| value / 100.0 }
  unit.convert_to(:a) { |value| value * 100.0 }
  unit.convert_to(:m2) { |value| value * 10_000.0 }
Severity: Minor
Found in lib/ruby-measurement/definitions/metric/area.rb and 1 other location - About 50 mins to fix
lib/ruby-measurement/definitions/metric/area.rb on lines 19..24

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

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

Measurement.define(:'in³') do |unit|
  unit.alias :in3, :'in^3', :'in*in*in', :'cubic inch', :'cubic inches'
  unit.convert_to(:'acre ft') { |value| value / 75_271_680.0 }
  unit.convert_to(:yd3) { |value| value / 46_656.0 }
  unit.convert_to(:ft3) { |value| value / 1_728.0 }
Severity: Minor
Found in lib/ruby-measurement/definitions/us_customary/capacity.rb and 1 other location - About 40 mins to fix
lib/ruby-measurement/definitions/us_customary/capacity.rb on lines 17..21

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

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

Measurement.define(:'ft³') do |unit|
  unit.alias :ft3, :'ft^3', :'ft*ft*ft', :'cubic foot', :'cubic feet'
  unit.convert_to(:'acre ft') { |value| value / 43_560.0 }
  unit.convert_to(:yd3) { |value| value / 27.0 }
  unit.convert_to(:in3) { |value| value * 1_728.0 }
Severity: Minor
Found in lib/ruby-measurement/definitions/us_customary/capacity.rb and 1 other location - About 40 mins to fix
lib/ruby-measurement/definitions/us_customary/capacity.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 37.

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

Method initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(quantity, unit_name = :count)
    unit = unit_name
    unit = Unit[unit_name.to_s] if unit_name.kind_of?(Symbol) || unit_name.kind_of?(String)

    raise ArgumentError, "Invalid quantity: '#{quantity}'" unless quantity.kind_of?(Numeric)
Severity: Minor
Found in lib/ruby-measurement/measurement.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

Measurement.define(:'m³') do |unit|
  unit.alias :m3, :'m^3', :'m*m*m', :'cubic meter', :'cubic meters'
  unit.convert_to(:dm3) { |value| value * 1_000.0 }
  unit.convert_to(:cm3) { |value| value * 1_000_000.0 }
Severity: Minor
Found in lib/ruby-measurement/definitions/metric/capacity.rb and 2 other locations - About 25 mins to fix
lib/ruby-measurement/definitions/metric/capacity.rb on lines 9..12
lib/ruby-measurement/definitions/metric/capacity.rb on lines 15..18

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

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

Measurement.define(:'cm³') do |unit|
  unit.alias :cm3, :'cm^3', :'cm*cm*cm', :'cubic centimeter', :'cubic centimeters'
  unit.convert_to(:m3) { |value| value / 1_000_000.0 }
  unit.convert_to(:dm3) { |value| value / 1_000.0 }
Severity: Minor
Found in lib/ruby-measurement/definitions/metric/capacity.rb and 2 other locations - About 25 mins to fix
lib/ruby-measurement/definitions/metric/capacity.rb on lines 3..6
lib/ruby-measurement/definitions/metric/capacity.rb on lines 9..12

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

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

Severity
Category
Status
Source
Language