Philzen/measurement.js

View on GitHub

Showing 13 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

          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

                    Avoid too many return statements within this function.
                    Open

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

                      Avoid too many return statements within this function.
                      Open

                                              return self.convert(baseValue);
                      Severity: Major
                      Found in measurement.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                                    return parseFloat(self.convert(baseValue).toFixed(10));
                        Severity: Major
                        Found in measurement.js - About 30 mins to fix

                          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