angular/angular.js

View on GitHub
src/ng/sce.js

Summary

Maintainability
F
4 days
Test Coverage

Function $SceDelegateProvider has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
Open

function $SceDelegateProvider() {
  this.SCE_CONTEXTS = SCE_CONTEXTS;

  // Resource URLs can also be trusted by policy.
  var trustedResourceUrlList = ['self'],
Severity: Minor
Found in src/ng/sce.js - About 1 day 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 $SceDelegateProvider has 143 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function $SceDelegateProvider() {
  this.SCE_CONTEXTS = SCE_CONTEXTS;

  // Resource URLs can also be trusted by policy.
  var trustedResourceUrlList = ['self'],
Severity: Major
Found in src/ng/sce.js - About 5 hrs to fix

    Function $get has 110 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      this.$get = ['$injector', '$$sanitizeUri', function($injector, $$sanitizeUri) {
    
        var htmlSanitizer = function htmlSanitizer(html) {
          throw $sceMinErr('unsafe', 'Attempting to use an unsafe value in a safe context.');
        };
    Severity: Major
    Found in src/ng/sce.js - About 4 hrs to fix

      Function $SceProvider has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function $SceProvider() {
        var enabled = true;
      
        /**
         * @ngdoc method
      Severity: Major
      Found in src/ng/sce.js - About 2 hrs to fix

        Function $get has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          this.$get = ['$parse', '$sceDelegate', function(
                        $parse,   $sceDelegate) {
            // Support: IE 9-11 only
            // Prereq: Ensure that we're not running in IE<11 quirks mode.  In that mode, IE < 11 allow
            // the "expression(javascript expression)" syntax which is insecure.
        Severity: Minor
        Found in src/ng/sce.js - About 1 hr to fix

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

          function $SceProvider() {
            var enabled = true;
          
            /**
             * @ngdoc method
          Severity: Minor
          Found in src/ng/sce.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

          Avoid too many return statements within this function.
          Open

                  return htmlSanitizer(maybeTrusted);
          Severity: Major
          Found in src/ng/sce.js - About 30 mins to fix

            Function adjustMatcher has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            function adjustMatcher(matcher) {
              if (matcher === 'self') {
                return matcher;
              } else if (isString(matcher)) {
                // Strings match exactly except for 2 wildcards - '*' and '**'.
            Severity: Minor
            Found in src/ng/sce.js - 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 2 locations. Consider refactoring.
            Open

                  for (i = 0, n = trustedResourceUrlList.length; i < n; i++) {
                    if (matchUrl(trustedResourceUrlList[i], parsedUrl)) {
                      allowed = true;
                      break;
                    }
            Severity: Major
            Found in src/ng/sce.js and 1 other location - About 1 hr to fix
            src/ng/sce.js on lines 323..328

            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

                    for (i = 0, n = bannedResourceUrlList.length; i < n; i++) {
                      if (matchUrl(bannedResourceUrlList[i], parsedUrl)) {
                        allowed = false;
                        break;
                      }
            Severity: Major
            Found in src/ng/sce.js and 1 other location - About 1 hr to fix
            src/ng/sce.js on lines 315..320

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

              Object.defineProperty(this, 'resourceUrlWhitelist', {
                get: function() {
                  return this.trustedResourceUrlList;
                },
                set: function(value) {
            Severity: Major
            Found in src/ng/sce.js and 2 other locations - About 1 hr to fix
            src/ng/compile.js on lines 1740..1747
            src/ng/compile.js on lines 1791..1798

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

              Object.defineProperty(this, 'resourceUrlBlacklist', {
                get: function() {
                  return this.bannedResourceUrlList;
                },
                set: function(value) {
            Severity: Major
            Found in src/ng/sce.js and 1 other location - About 1 hr to fix
            src/ng/http.js on lines 442..449

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

            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

              this.bannedResourceUrlList = function(value) {
                if (arguments.length) {
                  bannedResourceUrlList = adjustMatchers(value);
                }
                return bannedResourceUrlList;
            Severity: Minor
            Found in src/ng/sce.js and 1 other location - About 35 mins to fix
            src/ng/sce.js on lines 212..217

            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

              this.trustedResourceUrlList = function(value) {
                if (arguments.length) {
                  trustedResourceUrlList = adjustMatchers(value);
                }
                return trustedResourceUrlList;
            Severity: Minor
            Found in src/ng/sce.js and 1 other location - About 35 mins to fix
            src/ng/sce.js on lines 264..269

            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