Compass/compass

View on GitHub

Showing 168 of 168 total issues

Method examine has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def examine(io)
      class << io
        unless method_defined?(:readbyte)
          def readbyte
            getc
Severity: Minor
Found in core/lib/compass/core/sass_extensions/functions/image_size.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 write_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def write_file(file_name, contents, options = nil, binary = false)
      options ||= self.options if self.respond_to?(:options)
      skip_write = false
      contents = process_erb(contents, options[:erb]) if options[:erb]
      if File.exists?(file_name)
Severity: Minor
Found in cli/lib/compass/actions.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

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

      class << self

        def option_parser(arguments)
          parser = Compass::Exec::CommandOptionParser.new(arguments)
          parser.extend(Compass::Exec::GlobalOptionsParser)
Severity: Major
Found in cli/lib/compass/commands/validate_project.rb and 1 other location - About 1 hr to fix
cli/lib/compass/commands/write_configuration.rb on lines 87..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 65.

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

      class << self

        def option_parser(arguments)
          parser = Compass::Exec::CommandOptionParser.new(arguments)
          parser.extend(Compass::Exec::GlobalOptionsParser)
Severity: Major
Found in cli/lib/compass/commands/write_configuration.rb and 1 other location - About 1 hr to fix
cli/lib/compass/commands/validate_project.rb on lines 39..70

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

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 perform has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def perform
        super
        require 'compass/stats'
        compiler = new_compiler_instance
        sass_files = sorted_sass_files(compiler)
Severity: Minor
Found in cli/lib/compass/commands/project_stats.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 grad_point has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def grad_point(position)
            original_value = position
            position = unless position.is_a?(Sass::Script::Value::List)
              opts(list([position], :space))
            else
      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 compare_browser_versions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def compare_browser_versions(browser, version1, version2)
          assert_type browser, :String, :browser
          assert_type version1, :String, :version1
          assert_type version2, :String, :version2
          index1 = index2 = nil

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

          def perform!
            $command = args.shift
            command_class = Compass::Commands[$command]
            unless command_class
              args.unshift($command)
      Severity: Minor
      Found in cli/lib/compass/exec/sub_command_ui.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 installer has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.installer(type, installer_opts = {}, &locator)
              locator ||= lambda{|to| to}
              loc_method = "install_location_for_#{type}".to_sym
              define_method("simple_#{loc_method}", locator)
              define_method(loc_method) do |to, options|
      Severity: Minor
      Found in cli/lib/compass/installers/base.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 opposite_position has 35 lines of code (exceeds 25 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 1 hr to fix

        Function cookie has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        jQuery.cookie = function(name, value, options) {
            if (typeof value != 'undefined') { // name and value given, set cookie
                options = options || {};
                if (value === null) {
                    value = '';
        Severity: Minor
        Found in compass-style.org/assets/javascripts/jquery.cookie.js - 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 item_tree has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def item_tree(item, options = {})
              crumb = item[:crumb] || item[:title]
              options[:heading_level] ||= 1 if options.fetch(:headings, true)
              child_html = ""
              if options.fetch(:depth,1) > 0
            Severity: Minor
            Found in compass-style.org/lib/default.rb - About 1 hr to fix

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

              function setExampleMarkupSyntaxPreference (exampleMarkup) {
                $.cookie("compass-example-markup", null);
                $.cookie("compass-example-markup", exampleMarkup, { expires: 60 * 60 * 24 * 365 * 10, path: '/' });
              }
              Severity: Major
              Found in compass-style.org/assets/javascripts/site.js and 3 other locations - About 1 hr to fix
              compass-style.org/assets/javascripts/site.js on lines 34..40
              compass-style.org/assets/javascripts/site.js on lines 51..54
              compass-style.org/assets/javascripts/site.js on lines 56..59

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

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

              function setExampleStyleSyntaxPreference (exampleStyle) {
                $.cookie("compass-example-style", null);
                $.cookie("compass-example-style", exampleStyle, { expires: 60 * 60 * 24 * 365 * 10, path: '/' });
              }
              Severity: Major
              Found in compass-style.org/assets/javascripts/site.js and 3 other locations - About 1 hr to fix
              compass-style.org/assets/javascripts/site.js on lines 34..40
              compass-style.org/assets/javascripts/site.js on lines 51..54
              compass-style.org/assets/javascripts/site.js on lines 61..64

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

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

              function setThemePreference(theme) {
                $.cookie("compass-theme", null);
                $.cookie("compass-theme", theme, {
                  expires: 60 * 60 * 24 * 365 * 10,
                  path: '/'
              Severity: Major
              Found in compass-style.org/assets/javascripts/site.js and 3 other locations - About 1 hr to fix
              compass-style.org/assets/javascripts/site.js on lines 51..54
              compass-style.org/assets/javascripts/site.js on lines 56..59
              compass-style.org/assets/javascripts/site.js on lines 61..64

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

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

              function setStyleSyntaxPreference (mainSyntax) {
                $.cookie("compass-syntax", null);
                $.cookie("compass-syntax", mainSyntax, { expires: 60 * 60 * 24 * 365 * 10, path: '/' });
              }
              Severity: Major
              Found in compass-style.org/assets/javascripts/site.js and 3 other locations - About 1 hr to fix
              compass-style.org/assets/javascripts/site.js on lines 34..40
              compass-style.org/assets/javascripts/site.js on lines 56..59
              compass-style.org/assets/javascripts/site.js on lines 61..64

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

              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 set_options has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def set_options(opts)
              
                      if $command == "create"
                        opts.banner = %Q{
                          Usage: compass create path/to/project [options]
              Severity: Minor
              Found in cli/lib/compass/commands/create_project.rb - About 1 hr to fix

                Method grad_point has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def grad_point(position)
                      original_value = position
                      position = unless position.is_a?(Sass::Script::Value::List)
                        opts(list([position], :space))
                      else
                Severity: Minor
                Found in core/lib/compass/core/sass_extensions/functions/gradient_support.rb - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language