danmayer/coverband

View on GitHub

Showing 45 of 45 total issues

Class Configuration has 36 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Configuration
    attr_accessor :root_paths, :root,
      :verbose,
      :reporter, :redis_namespace, :redis_ttl,
      :background_reporting_enabled,
Severity: Minor
Found in lib/coverband/configuration.rb - About 4 hrs to fix

    Method start has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.start
          return if running?
    
          logger = Coverband.configuration.logger
          @semaphore.synchronize do
    Severity: Minor
    Found in lib/coverband/integrations/background.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 report_coverage has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

          def report_coverage
            @semaphore.synchronize do
              raise "no Coverband store set" unless @store
    
              files_with_line_usage = filtered_files(Delta.results)
    Severity: Minor
    Found in lib/coverband/collectors/coverage.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

    Class HTMLFormatter has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class HTMLFormatter
          attr_reader :notice, :base_path, :tracker, :page
    
          def initialize(report, options = {})
            @notice = options.fetch(:notice, nil)
    Severity: Minor
    Found in lib/coverband/utils/html_formatter.rb - About 3 hrs to fix

      Class HashRedisStore has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class HashRedisStore < Base
            FILE_KEY = "file"
            FILE_LENGTH_KEY = "file_length"
            META_DATA_KEYS = [DATA_KEY, FIRST_UPDATED_KEY, LAST_UPDATED_KEY, FILE_HASH].freeze
            ###
      Severity: Minor
      Found in lib/coverband/adapters/hash_redis_store.rb - About 3 hrs to fix

        Class SourceFile has 26 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class SourceFile
              # TODO: Refactor Line into its own file
              # Representation of a single line in a source file including
              # this specific line's source code, line_number and code coverage,
              # with the coverage being either nil (coverage not applicable, e.g. comment
        Severity: Minor
        Found in lib/coverband/utils/source_file.rb - About 3 hrs to fix

          Class AbstractTracker has 23 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class AbstractTracker
                REPORT_ROUTE = "/"
                TITLE = "abstract"
          
                attr_accessor :target
          Severity: Minor
          Found in lib/coverband/collectors/abstract_tracker.rb - About 2 hrs to fix

            Method call has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                  def call(env)
                    @request = Rack::Request.new(env)
            
                    return [401, {"www-authenticate" => 'Basic realm=""'}, [""]] unless check_auth
            
            
            Severity: Minor
            Found in lib/coverband/reporters/web.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 array_add has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                  def array_add(latest, original)
                    if latest.empty? && original.empty?
                      []
                    elsif Coverband.configuration.use_oneshot_lines_coverage
                      latest.map!.with_index { |v, i| ((v + original[i] >= 1) ? 1 : 0) if v && original[i] }
            Severity: Minor
            Found in lib/coverband/adapters/base.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 generate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                  def generate
                    current_coverage.each_with_object({}) do |(file, line_counts), new_results|
                      ###
                      # Eager filter:
                      # Normally I would break this out into additional methods
            Severity: Minor
            Found in lib/coverband/collectors/delta.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

            File configuration.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Coverband
              ###
              # Configuration parsing and options for the coverband gem.
              ###
              class Configuration
            Severity: Minor
            Found in lib/coverband/configuration.rb - About 2 hrs to fix

              Method call has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def call(env)
                      @request = Rack::Request.new(env)
              
                      return [401, {"www-authenticate" => 'Basic realm=""'}, [""]] unless check_auth
              
              
              Severity: Major
              Found in lib/coverband/reporters/web.rb - About 2 hrs to fix

                Method reset has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def reset
                      @root = Dir.pwd
                      @root_paths = []
                      @ignore = IGNORE_DEFAULTS.map { |ignore_str| Regexp.new(ignore_str) }
                      @search_paths = TRACKED_DEFAULT_PATHS.dup
                Severity: Minor
                Found in lib/coverband/configuration.rb - About 1 hr to fix

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

                          def get_current_scov_data_imp(store, roots, options = {})
                            scov_style_report = {}
                            store.get_coverage_report(options).each_pair do |name, data|
                              data.each_pair do |key, line_data|
                                next if Coverband.configuration.ignore.any? { |i| key.match?(i) }
                  Severity: Minor
                  Found in lib/coverband/reporters/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 initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def initialize
                          @semaphore = Mutex.new
                  
                          require "coverage"
                          if RUBY_PLATFORM == "java"
                  Severity: Minor
                  Found in lib/coverband/collectors/coverage.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 report_as_json has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def report_as_json
                          return filtered_report_files.to_json if for_merged_report
                  
                          result = Coverband::Utils::Results.new(filtered_report_files)
                          source_files = result.source_files
                  Severity: Minor
                  Found in lib/coverband/reporters/json_report.rb - About 1 hr to fix

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

                                setTimeout(() => {
                                  if (window.auto_click_anchor && $(window.auto_click_anchor).length > 0) {
                                    $(window.auto_click_anchor).click();
                                  }
                                }, 50)
                    Severity: Major
                    Found in public/application.js and 1 other location - About 1 hr to fix
                    public/application.js on lines 175..179

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

                          setTimeout(() => {
                            if (window.auto_click_anchor && $(window.auto_click_anchor).length > 0) {
                              $(window.auto_click_anchor).click();
                            }
                          }, 30);
                    Severity: Major
                    Found in public/application.js and 1 other location - About 1 hr to fix
                    public/application.js on lines 72..76

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

                          def build_response(req)
                            uri = URI.parse(path(req.path_parameters, req))
                    
                            unless uri.host
                              if relative_path?(uri.path)
                    Severity: Minor
                    Found in lib/coverband/utils/rails6_ext.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 track_key has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def track_key(payload)
                            if (file = payload[:identifier])
                              if newly_seen_key?(file)
                                @logged_keys << file
                                @keys_to_record << file if track_file?(file)
                    Severity: Minor
                    Found in lib/coverband/collectors/view_tracker.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