Compass/compass

View on GitHub
core/lib/compass/core/sass_extensions/functions/urls.rb

Summary

Maintainability
D
2 days
Test Coverage

Method image_url has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    def image_url(path, only_path = bool(false), cache_buster = bool(true))
      path = path.value # get to the string value of the literal.

      if path =~ %r{^#{Regexp.escape(Compass.configuration.http_images_path)}/(.*)}
        # Treat root relative urls (without a protocol) like normal if they start with
Severity: Minor
Found in core/lib/compass/core/sass_extensions/functions/urls.rb - About 4 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

Method generated_image_url has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def generated_image_url(path, cache_buster = bool(false))
      path = path.value # get to the string value of the literal.

      if path =~ %r{^#{Regexp.escape(Compass.configuration.http_generated_images_path)}/(.*)}
        # Treat root relative urls (without a protocol) like normal if they start with
Severity: Minor
Found in core/lib/compass/core/sass_extensions/functions/urls.rb - 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

Method font_url has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def font_url(path, only_path = bool(false), cache_buster = bool(true))
      path = path.value # get to the string value of the literal.

      # Short curcuit if they have provided an absolute url.
      if absolute_path?(path)
Severity: Minor
Found in core/lib/compass/core/sass_extensions/functions/urls.rb - 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

Method image_url has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def image_url(path, only_path = bool(false), cache_buster = bool(true))
      path = path.value # get to the string value of the literal.

      if path =~ %r{^#{Regexp.escape(Compass.configuration.http_images_path)}/(.*)}
        # Treat root relative urls (without a protocol) like normal if they start with
Severity: Minor
Found in core/lib/compass/core/sass_extensions/functions/urls.rb - About 1 hr to fix

    Method generated_image_url has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def generated_image_url(path, cache_buster = bool(false))
          path = path.value # get to the string value of the literal.
    
          if path =~ %r{^#{Regexp.escape(Compass.configuration.http_generated_images_path)}/(.*)}
            # Treat root relative urls (without a protocol) like normal if they start with
    Severity: Minor
    Found in core/lib/compass/core/sass_extensions/functions/urls.rb - About 1 hr to fix

      Method font_url has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def font_url(path, only_path = bool(false), cache_buster = bool(true))
            path = path.value # get to the string value of the literal.
      
            # Short curcuit if they have provided an absolute url.
            if absolute_path?(path)
      Severity: Minor
      Found in core/lib/compass/core/sass_extensions/functions/urls.rb - About 1 hr to fix

        Method compute_cache_buster has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def compute_cache_buster(path, real_path)
            file = nil
            if Compass.configuration.asset_cache_buster
              args = [path]
              if Compass.configuration.asset_cache_buster.arity > 1
        Severity: Minor
        Found in core/lib/compass/core/sass_extensions/functions/urls.rb - 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

        Method included has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.included(base)
            base.send(:include, StylesheetUrl) unless has?(base, :stylesheet_url)
            base.send(:include, FontUrl) unless has?(base, :font_url)
            base.send(:include, ImageUrl) unless has?(base, :image_url)
            base.send(:include, GeneratedImageUrl) unless has?(base, :generated_image_url)
        Severity: Minor
        Found in core/lib/compass/core/sass_extensions/functions/urls.rb - 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

        Method cache_busted_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def cache_busted_path(path, real_path)
            cache_buster = compute_cache_buster(path, real_path)
            if cache_buster.nil?
              return path
            elsif cache_buster.is_a?(String)
        Severity: Minor
        Found in core/lib/compass/core/sass_extensions/functions/urls.rb - 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

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

              if cache_buster.to_bool
                path, anchor = path.split("#", 2)
                if cache_buster.is_a?(Sass::Script::Value::String)
                  path += "#{path["?"] ? "&" : "?"}#{cache_buster.value}"
                else
        Severity: Major
        Found in core/lib/compass/core/sass_extensions/functions/urls.rb and 2 other locations - About 1 hr to fix
        core/lib/compass/core/sass_extensions/functions/urls.rb on lines 153..160
        core/lib/compass/core/sass_extensions/functions/urls.rb on lines 222..229

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

        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

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

              if cache_buster.to_bool
                path, anchor = path.split("#", 2)
                if cache_buster.is_a?(Sass::Script::Value::String)
                  path += "#{path["?"] ? "&" : "?"}#{cache_buster.value}"
                else
        Severity: Major
        Found in core/lib/compass/core/sass_extensions/functions/urls.rb and 2 other locations - About 1 hr to fix
        core/lib/compass/core/sass_extensions/functions/urls.rb on lines 83..90
        core/lib/compass/core/sass_extensions/functions/urls.rb on lines 222..229

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

        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

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

              if cache_buster.to_bool
                path, anchor = path.split("#", 2)
                if cache_buster.is_a?(Sass::Script::Value::String)
                  path += "#{path["?"] ? "&" : "?"}#{cache_buster.value}"
                else
        Severity: Major
        Found in core/lib/compass/core/sass_extensions/functions/urls.rb and 2 other locations - About 1 hr to fix
        core/lib/compass/core/sass_extensions/functions/urls.rb on lines 83..90
        core/lib/compass/core/sass_extensions/functions/urls.rb on lines 153..160

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

        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

            def self.included(base)
              if base.respond_to?(:declare)
                base.declare :font_url,       [:path]
                base.declare :font_url,       [:path, :only_path]
                base.declare :font_url,       [:path, :only_path, :cache_buster]
        Severity: Minor
        Found in core/lib/compass/core/sass_extensions/functions/urls.rb and 1 other location - About 15 mins to fix
        core/lib/compass/core/sass_extensions/functions/urls.rb on lines 105..109

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

        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

            def self.included(base)
              if base.respond_to?(:declare)
                base.declare :image_url,      [:path]
                base.declare :image_url,      [:path, :only_path]
                base.declare :image_url,      [:path, :only_path, :cache_buster]
        Severity: Minor
        Found in core/lib/compass/core/sass_extensions/functions/urls.rb and 1 other location - About 15 mins to fix
        core/lib/compass/core/sass_extensions/functions/urls.rb on lines 43..47

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

        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