olbrich/ruby-units

View on GitHub
lib/ruby_units/unit_definitions/standard.rb

Summary

Maintainability
C
1 day
Test Coverage
A
100%

File standard.rb has 520 lines of code (exceeds 250 allowed). Consider refactoring.
Open

RubyUnits::Unit.define("inch") do |inch|
  inch.definition = RubyUnits::Unit.new("254/10000 meter")
  inch.aliases    = %w[in inch inches "]
end

Severity: Major
Found in lib/ruby_units/unit_definitions/standard.rb - About 1 day to fix

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

    RubyUnits::Unit.define("cmh2o") do |cmh2o|
      density_of_water  = RubyUnits::Unit.new("1 g/cm^3") # at 4 tempC
      cmh2o.definition  = RubyUnits::Unit.new("1 cm") * RubyUnits::Unit.new("1 gee") * density_of_water
      cmh2o.aliases     = %w[cmH2O cmh2o cmAq]
    Severity: Minor
    Found in lib/ruby_units/unit_definitions/standard.rb and 1 other location - About 25 mins to fix
    lib/ruby_units/unit_definitions/standard.rb on lines 439..442

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

    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

    RubyUnits::Unit.define("inh2o") do |inh2o|
      density_of_water  = RubyUnits::Unit.new("1 g/cm^3") # at 4 tempC
      inh2o.definition  = RubyUnits::Unit.new("1 in") * RubyUnits::Unit.new("1 gee") * density_of_water
      inh2o.aliases     = %w[inH2O inh2o inAq]
    Severity: Minor
    Found in lib/ruby_units/unit_definitions/standard.rb and 1 other location - About 25 mins to fix
    lib/ruby_units/unit_definitions/standard.rb on lines 433..436

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

    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

    RubyUnits::Unit.define("inHg") do |inhg|
      density_of_mercury = RubyUnits::Unit.new("7653360911758079/562949953421312 g/cm^3") # 13.5951 g/cm^3 at 0 tempC
      inhg.definition    = RubyUnits::Unit.new("1 in") * RubyUnits::Unit.new("1 gee") * density_of_mercury
    Severity: Minor
    Found in lib/ruby_units/unit_definitions/standard.rb and 1 other location - About 15 mins to fix
    lib/ruby_units/unit_definitions/standard.rb on lines 414..416

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

    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

    RubyUnits::Unit.define("mmHg") do |mmhg|
      density_of_mercury  = RubyUnits::Unit.new("7653360911758079/562949953421312 g/cm^3") # 13.5951 g/cm^3 at 0 tempC
      mmhg.definition     = RubyUnits::Unit.new("1 mm") * RubyUnits::Unit.new("1 gee") * density_of_mercury
    Severity: Minor
    Found in lib/ruby_units/unit_definitions/standard.rb and 1 other location - About 15 mins to fix
    lib/ruby_units/unit_definitions/standard.rb on lines 419..421

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

    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