angular/angular.js

View on GitHub
src/ng/filter/filters.js

Summary

Maintainability
D
2 days
Test Coverage

File filters.js has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var MAX_DIGITS = 22;
var DECIMAL_SEP = '.';
var ZERO_CHAR = '0';
Severity: Minor
Found in src/ng/filter/filters.js - About 3 hrs to fix

    Function formatNumber has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
    
      if (!(isString(number) || isNumber(number)) || isNaN(number)) return '';
    
      var isInfinity = !isFinite(number);
    Severity: Minor
    Found in src/ng/filter/filters.js - About 3 hrs 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

    Function dateFilter has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function dateFilter($locale) {
    
    
      var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
                         // 1        2       3         4          5          6          7          8  9     10      11
    Severity: Major
    Found in src/ng/filter/filters.js - About 2 hrs to fix

      Function roundNumber has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      function roundNumber(parsedNumber, fractionSize, minFrac, maxFrac) {
          var digits = parsedNumber.d;
          var fractionLen = digits.length - parsedNumber.i;
      
          // determine fractionSize if it is not specified; `+fractionSize` converts it to a number
      Severity: Minor
      Found in src/ng/filter/filters.js - About 2 hrs 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

      Function formatNumber has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
      
        if (!(isString(number) || isNumber(number)) || isNaN(number)) return '';
      
        var isInfinity = !isFinite(number);
      Severity: Minor
      Found in src/ng/filter/filters.js - About 1 hr to fix

        Function parse has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        function parse(numStr) {
          var exponent = 0, digits, numberOfIntegerDigits;
          var i, j, zeros;
        
          // Decimal point?
        Severity: Minor
        Found in src/ng/filter/filters.js - About 1 hr 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

        Function roundNumber has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function roundNumber(parsedNumber, fractionSize, minFrac, maxFrac) {
            var digits = parsedNumber.d;
            var fractionLen = digits.length - parsedNumber.i;
        
            // determine fractionSize if it is not specified; `+fractionSize` converts it to a number
        Severity: Minor
        Found in src/ng/filter/filters.js - About 1 hr to fix

          Function dateFilter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function dateFilter($locale) {
          
          
            var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
                               // 1        2       3         4          5          6          7          8  9     10      11
          Severity: Minor
          Found in src/ng/filter/filters.js - About 1 hr 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

          Function parse has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function parse(numStr) {
            var exponent = 0, digits, numberOfIntegerDigits;
            var i, j, zeros;
          
            // Decimal point?
          Severity: Minor
          Found in src/ng/filter/filters.js - About 1 hr to fix

            Function padNumber has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function padNumber(num, digits, trim, negWrap) {
              var neg = '';
              if (num < 0 || (negWrap && num <= 0)) {
                if (negWrap) {
                  num = -num + 1;
            Severity: Minor
            Found in src/ng/filter/filters.js - About 45 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

            Function formatNumber has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
            Severity: Minor
            Found in src/ng/filter/filters.js - About 35 mins to fix

              Function dateGetter has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function dateGetter(name, size, offset, trim, negWrap) {
              Severity: Minor
              Found in src/ng/filter/filters.js - About 35 mins to fix

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

                      if (match[9]) {
                        tzHour = toInt(match[9] + match[10]);
                        tzMin = toInt(match[9] + match[11]);
                      }
                Severity: Major
                Found in src/ng/filter/filters.js and 1 other location - About 1 hr to fix
                src/ngMock/angular-mocks.js on lines 690..693

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

                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

                function eraGetter(date, formats) {
                  return date.getFullYear() <= 0 ? formats.ERAS[0] : formats.ERAS[1];
                }
                Severity: Minor
                Found in src/ng/filter/filters.js and 2 other locations - About 35 mins to fix
                src/ng/filter/filters.js on lines 435..437
                src/ng/filter/filters.js on lines 443..445

                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

                function longEraGetter(date, formats) {
                  return date.getFullYear() <= 0 ? formats.ERANAMES[0] : formats.ERANAMES[1];
                }
                Severity: Minor
                Found in src/ng/filter/filters.js and 2 other locations - About 35 mins to fix
                src/ng/filter/filters.js on lines 435..437
                src/ng/filter/filters.js on lines 439..441

                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

                function ampmGetter(date, formats) {
                  return date.getHours() < 12 ? formats.AMPMS[0] : formats.AMPMS[1];
                }
                Severity: Minor
                Found in src/ng/filter/filters.js and 2 other locations - About 35 mins to fix
                src/ng/filter/filters.js on lines 439..441
                src/ng/filter/filters.js on lines 443..445

                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

                There are no issues that match your filters.

                Category
                Status