Compass/compass

View on GitHub

Showing 168 of 168 total issues

File inheritance.rb has 263 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Compass
  module Configuration
    # The inheritance module makes it easy for configuration data to inherit from
    # other instances of configuration data. This makes it easier for external code to layer
    # bits of configuration from various sources.
Severity: Minor
Found in core/lib/compass/configuration/inheritance.rb - About 2 hrs to fix

    Method opposite_position has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      def opposite_position(position)
        position = unless position.is_a?(Sass::Script::Value::List)
          list(position, :space)
        else
          list(position.value.dup, position.separator)
    Severity: Minor
    Found in core/lib/compass/core/sass_extensions/functions/constants.rb - 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

    Method to_sass_plugin_options has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def to_sass_plugin_options
            locations = []
            locations << [sass_path, css_path] if sass_path && css_path
            Compass::Frameworks::ALL.each do |framework|
              locations << [framework.stylesheets_directory, File.join(css_path || css_dir || ".", framework.name)]
    Severity: Minor
    Found in core/lib/compass/configuration/adapters.rb - 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 Brush has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function Brush()
        {
            function getKeywordsCSS(str)
            {
                return '\\b([a-z_]|)' + str.replace(/ /g, '(?=:)\\b|\\b([a-z_\\*]|\\*|)') + '(?=:)\\b';
    Severity: Major
    Found in compass-style.org/assets/javascripts/shBrushCss.js - About 2 hrs to fix

      Function Brush has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function Brush()
          {
              function getKeywordsSCSS(str)
              {
                  return '\\b([a-z_]|)' + str.replace(/ /g, '(?=:)\\b|\\b([a-z_\\*]|\\*|)') + '(?=:)\\b';
      Severity: Major
      Found in compass-style.org/assets/javascripts/shBrushScss.js - About 2 hrs to fix

        Method with_each_font_file has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def with_each_font_file(*args)
            skip_next = false
        
            args.each_with_index do |path, index|
              assert_type path, :String
        Severity: Minor
        Found in core/lib/compass/core/sass_extensions/functions/font_files.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 inherited_array has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def inherited_array(*attributes)
                  options = attributes.last.is_a?(Hash) ? attributes.pop : {}
                  inherited_reader(*attributes)
                  inherited_writer(*attributes)
                  attributes.each do |attr|
        Severity: Minor
        Found in core/lib/compass/configuration/inheritance.rb - About 1 hr to fix

          Method set_project_options has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def set_project_options(opts)
              opts.on('-c', '--config CONFIG_FILE', 'Specify the location of the configuration file explicitly.') do |configuration_file|
                self.options[:configuration_file] = configuration_file
              end
          
          
          Severity: Minor
          Found in cli/lib/compass/exec/project_options_parser.rb - About 1 hr to fix

            Method grad_position has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def grad_position(color_list, index, default, radial = bool(false))
                  assert_type color_list, :List
                  stop = color_list.value[index.value - 1].stop
                  if stop && radial.to_bool
                    orig_stop = stop
            Severity: Minor
            Found in core/lib/compass/core/sass_extensions/functions/gradient_support.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 add_project_configuration has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def add_project_configuration(*args)
                    options = args.last.is_a?(Hash) ? args.pop : {}
                    configuration_file_path = args.shift || detect_configuration_file
            
                    raise ArgumentError, "Too many arguments" if args.any?
            Severity: Minor
            Found in cli/lib/compass/configuration/helpers.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 serialize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def serialize
                    contents = ""
                    (required_libraries || []).each do |lib|
                      contents << %Q{require '#{lib}'\n}
                    end
            Severity: Minor
            Found in cli/lib/compass/configuration/serialization.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 visit_depth_first has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                    def visit_depth_first(visitor)
                      visitor.visit(self)
                      visitor.down(self) if children.any? and visitor.respond_to?(:down)
                      if is_a?(ImportNode) && visitor.import?(self)
                        root = Sass::Engine.for_file(import, @options).to_tree
            Severity: Minor
            Found in core/lib/compass/core/sass_extensions/monkey_patches/traversal.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 add_sass_configuration has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def add_sass_configuration(project_path)
                css_location = template_location = nil
                if options[:template_location] && options[:template_location].is_a?(Array)
                  css_location = File.expand_path(options[:template_location].first.last)
                  template_location = File.expand_path(options[:template_location].first.first)
            Severity: Minor
            Found in core/lib/compass/core/sass_extensions/functions/configuration.rb - About 1 hr to fix

              Method set_global_options has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def set_global_options(opts)
                  opts.on('-r LIBRARY', '--require LIBRARY',
                          "Require the given ruby LIBRARY before running commands.",
                          "  This is used to access compass plugins without having a",
                          "  project configuration file."
              Severity: Minor
              Found in cli/lib/compass/exec/global_options_parser.rb - About 1 hr to fix

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

                def mixins(item)
                  sass_tree = tree(item)
                  mixins = []
                  comment = nil
                  sass_tree.children.each do |child|
                Severity: Major
                Found in compass-style.org/lib/stylesheets.rb and 1 other location - About 1 hr to fix
                compass-style.org/lib/stylesheets.rb on lines 146..163

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

                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 functions(item)
                  sass_tree = tree(item)
                  functions = []
                  comment = nil
                  sass_tree.children.each do |child|
                Severity: Major
                Found in compass-style.org/lib/stylesheets.rb and 1 other location - About 1 hr to fix
                compass-style.org/lib/stylesheets.rb on lines 101..118

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

                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

                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 discover has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def discover(type)
                          type = self.class.plural_types[type] || type
                          dir = File.dirname(@manifest_file)
                          Dir.glob("#{dir}/**/*").each do |file|
                            next if /manifest\.rb/ =~ file
                  Severity: Minor
                  Found in cli/lib/compass/installers/manifest.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 omitted_usage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def omitted_usage(browser, min_version, max_version = nil)
                      versions = versions(browser)
                      min_version = caniuse_version(browser, min_version)
                      max_version = caniuse_version(browser, max_version)
                      if max_version.nil?
                  Severity: Minor
                  Found in core/lib/compass/core/caniuse.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 md5sum has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def md5sum(file, format = nil)
                      assert_type file, :String
                      filename = nil
                      if options[:css_filename] && File.exists?(options[:css_filename])
                        filename = File.expand_path(file.value, File.dirname(options[:css_filename]))
                  Severity: Minor
                  Found in core/lib/compass/core/sass_extensions/functions/files.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

                  Severity
                  Category
                  Status
                  Source
                  Language