Philzen/measurement.js

View on GitHub

Showing 23 of 23 total issues

File measurement.js has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open


/**
 * Measurement.Js
 * 
 * Unit-of-Measure conversion made easy.
Severity: Minor
Found in measurement.js - About 4 hrs to fix

    Function MeasurementConverter has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function MeasurementConverter(unitType) {
            var inputUnit = null,
                outputUnit = null,
                self = this;
    
    
    Severity: Major
    Found in measurement.js - About 2 hrs to fix

      Function exports has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function(config) {
        config.set({
      
          // base path that will be used to resolve all patterns (eg. files, exclude)
          basePath: './',
      Severity: Minor
      Found in karma.conf.js - About 2 hrs to fix

        Function convert has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                this.convert = function(value) {
        
                    if (DEFINITIONS[unitType]) {
                        var inputDef = DEFINITIONS[unitType][inputUnit],
                            outputDef = DEFINITIONS[unitType][outputUnit];
        Severity: Minor
        Found in measurement.js - About 1 hr to fix

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

                      'hPa': {
                          key: UNIT.Pressure.HECTOPASCAL,
                          base: 'Pa',
                          factor: 100,
                          name: {
          Severity: Major
          Found in measurement.js and 1 other location - About 1 hr to fix
          measurement.js on lines 143..155

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

          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

                      'bar': {
                          key: UNIT.Pressure.BAR,
                          base: 'Pa',
                          factor: 1000000,
                          name: {
          Severity: Major
          Found in measurement.js and 1 other location - About 1 hr to fix
          measurement.js on lines 118..130

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

          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

                      'kg': {
                          key: UNIT.Mass.KILOGRAM,
                          base: UNIT.Mass.GRAM,
                          factor: 1000,
                          name: {
          Severity: Major
          Found in measurement.js and 3 other locations - About 1 hr to fix
          measurement.js on lines 231..241
          measurement.js on lines 242..252
          measurement.js on lines 253..263

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

          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

                      'oz': {
                          key: UNIT.Mass.OUNCE,
                          base: UNIT.Mass.GRAM,
                          factor: 28.350,
                          name: {
          Severity: Major
          Found in measurement.js and 3 other locations - About 1 hr to fix
          measurement.js on lines 209..219
          measurement.js on lines 231..241
          measurement.js on lines 253..263

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

          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

                      'mg': {
                          key: UNIT.Mass.MILLIGRAM,
                          base: UNIT.Mass.GRAM,
                          factor: 0.001,
                          name: {
          Severity: Major
          Found in measurement.js and 3 other locations - About 1 hr to fix
          measurement.js on lines 209..219
          measurement.js on lines 242..252
          measurement.js on lines 253..263

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

          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

                      'lb': {
                          key: UNIT.Mass.POUND,
                          base: UNIT.Mass.GRAM,
                          factor: 453.6,
                          name: {
          Severity: Major
          Found in measurement.js and 3 other locations - About 1 hr to fix
          measurement.js on lines 209..219
          measurement.js on lines 231..241
          measurement.js on lines 242..252

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

          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

                                  } else if (baseType === outputDef.base) {
                                      baseValue = mjs(unitType).convert(value).from(outputDef.key).to(outputDef.base);
                                      inputUnit = outputDef.base;
                                  }
          Severity: Major
          Found in measurement.js and 1 other location - About 1 hr to fix
          measurement.js on lines 305..311

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

          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

                                  if (baseType === inputDef.base) {
                                      baseValue = mjs(unitType).convert(value).from(inputDef.key).to(inputDef.base);
                                      inputUnit = inputDef.base;
                                  } else if (baseType === outputDef.base) {
                                      baseValue = mjs(unitType).convert(value).from(outputDef.key).to(outputDef.base);
          Severity: Major
          Found in measurement.js and 1 other location - About 1 hr to fix
          measurement.js on lines 308..311

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

          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

          Function MeasurementJs has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function MeasurementJs(UnitType) {
                  var self = this;
                  /**
                   * 
                   * @param {type} value
          Severity: Minor
          Found in measurement.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (baseType === inputDef.base) {
                                        baseValue = mjs(unitType).convert(value).from(inputDef.key).to(inputDef.base);
                                        inputUnit = inputDef.base;
                                    } else if (baseType === outputDef.base) {
                                        baseValue = mjs(unitType).convert(value).from(outputDef.key).to(outputDef.base);
            Severity: Major
            Found in measurement.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (baseType === UNIT.Temperature.CELSIUS) {
                                          return parseFloat(self.convert(baseValue).toFixed(10));
                                      }
              Severity: Major
              Found in measurement.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if (typeof outputDef.factor === 'function') {
                                            return outputDef.factor(value, true);
                                        }
                Severity: Major
                Found in measurement.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if (typeof baseType === 'undefined') {
                                              return false;
                                          }
                  Severity: Major
                  Found in measurement.js - About 45 mins to fix

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

                                    to: function(outputUnit) {
                                        converter.setOutputUnit(outputUnit);
                                        if (readyToConvert()) {
                                            return converter.convert(valueToConvert);
                                        }
                    Severity: Minor
                    Found in measurement.js and 1 other location - About 35 mins to fix
                    measurement.js on lines 358..365

                    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

                                    from: function(inputUnit) {
                                        converter.setInputUnit(inputUnit);
                                        if (readyToConvert()) {
                                            return converter.convert(valueToConvert);
                                        }
                    Severity: Minor
                    Found in measurement.js and 1 other location - About 35 mins to fix
                    measurement.js on lines 366..373

                    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

                    Avoid too many return statements within this function.
                    Open

                                return false;
                    Severity: Major
                    Found in measurement.js - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language