danmayer/coverband

View on GitHub

Showing 42 of 46 total issues

Method coverage_for_types has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def coverage_for_types(_types, opts = {})
        page_size = opts[:page_size] || 250
        hash_data = {}

        runtime_file_set = files_set(Coverband::RUNTIME_TYPE)
Severity: Minor
Found in lib/coverband/adapters/hash_redis_store.rb - About 1 hr to fix

    Method coverage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def coverage(local_type = nil, opts = {})
            return if Coverband.configuration.service_disabled_dev_test_env?
    
            local_type ||= opts.key?(:override_type) ? opts[:override_type] : type
            env_filter = opts.key?(:env_filter) ? opts[:env_filter] : "production"
    Severity: Minor
    Found in lib/coverband/adapters/web_service_store.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 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def initialize
            @semaphore = Mutex.new
            raise NotImplementedError, "Coverage needs Ruby > 2.3.0" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.3.0")
    
            require "coverage"
    Severity: Minor
    Found in lib/coverband/collectors/coverage.rb - About 1 hr to fix

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

            def merge_reports(new_report, old_report, options = {})
              # transparently update from RUNTIME_TYPE = nil to RUNTIME_TYPE = :runtime
              # transparent update for format coverband_3_2
              old_report = coverage(nil, override_type: nil) if old_report.nil? && type == Coverband::RUNTIME_TYPE
              new_report = expand_report(new_report) unless options[:skip_expansion]
      Severity: Minor
      Found in lib/coverband/adapters/base.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 scan_node has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def scan_node(node, class_name)
                definitions = []
                return definitions unless node.is_a?(RubyVM::AbstractSyntaxTree::Node)
                current_class = (node.type == :CLASS) ? node.children.first.children.last : class_name
                if node.type == :DEFN
      Severity: Minor
      Found in lib/coverband/utils/method_definition_scanner.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 register has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.register
            return if ENV["COVERBAND_DISABLE_AT_EXIT"]
            return if @at_exit_registered
      
            @semaphore.synchronize do
      Severity: Minor
      Found in lib/coverband/at_exit.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 build_lines has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def build_lines
              coverage_exceeding_source_warn if coverage.size > src.size
      
              lines = src.map.with_index(1) { |src, i|
                Coverband::Utils::SourceFile::Line.new(
      Severity: Minor
      Found in lib/coverband/utils/source_file.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 track_key has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def track_key(payload)
              route = if payload.key?(:location)
                # For redirect.action_dispatch
                return unless Coverband.configuration.track_redirect_routes
      
      
      Severity: Minor
      Found in lib/coverband/collectors/route_tracker.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 runtime_relevant_coverage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def runtime_relevant_coverage(source_file)
              return unless eager_loading_coverage && runtime_coverage
      
              eager_file = get_eager_file(source_file)
              runtime_file = get_runtime_file(source_file)
      Severity: Minor
      Found in lib/coverband/utils/results.rb - About 35 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 save_report has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def save_report(report)
              report_time = Time.now.to_i
              updated_time = (type == Coverband::EAGER_TYPE) ? nil : report_time
              keys = []
              report.each_slice(@save_report_batch_size) do |slice|
      Severity: Minor
      Found in lib/coverband/adapters/hash_redis_store.rb - About 35 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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def initialize(src, line_number, coverage, coverage_posted = nil)
                raise ArgumentError, "Only String accepted for source" unless src.is_a?(String)
                raise ArgumentError, "Only Integer accepted for line_number" unless line_number.is_a?(Integer)
                raise ArgumentError, "Only Integer and nil accepted for coverage" unless coverage.is_a?(Integer) || coverage.nil?
      
      
      Severity: Minor
      Found in lib/coverband/utils/source_file.rb - About 35 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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def initialize(filename, file_data)
              @filename = filename
              @runtime_relavant_lines = nil
              if file_data.is_a?(Hash)
                @coverage = file_data["data"]
      Severity: Minor
      Found in lib/coverband/utils/source_file.rb - About 35 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 split_coverage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def split_coverage(types, coverage_cache, options = {})
              types.reduce({}) do |data, type|
                if type == Coverband::RUNTIME_TYPE && Coverband.configuration.simulate_oneshot_lines_coverage
                  data.update(type => coverage_cache[type] ||= simulated_runtime_coverage)
                else
      Severity: Minor
      Found in lib/coverband/adapters/base.rb - 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

      Method track_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def track_key(key)
              if key
                if newly_seen_key?(key)
                  @logged_keys << key
                  @keys_to_record << key if track_key?(key)
      Severity: Minor
      Found in lib/coverband/collectors/abstract_tracker.rb - 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

      Method runtime_relavent_lines has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def runtime_relavent_lines(source_file)
              return 0 unless runtime_coverage
      
              eager_file = get_eager_file(source_file)
              runtime_file = get_runtime_file(source_file)
      Severity: Minor
      Found in lib/coverband/utils/results.rb - 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

      Method check_auth has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def check_auth
              return true unless Coverband.configuration.password
      
              # support rack 1.6.x and rack 2.0 (get_header)
              auth_header = request.respond_to?(:get_header) ? request.get_header("HTTP_AUTHORIZATION") : request.env["HTTP_AUTHORIZATION"]
      Severity: Minor
      Found in lib/coverband/reporters/web.rb - 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

      Method transform_oneshot_lines_results has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

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

      Method fix_file_names has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def fix_file_names(report_hash, roots)
                Coverband.configuration.logger.debug "fixing root: #{roots.join(", ")}" if Coverband.configuration.verbose
      
                # normalize names across servers
                report_hash.each_with_object({}) do |(name, report), fixed_report|
      Severity: Minor
      Found in lib/coverband/reporters/base.rb - 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

      Method add_coverage_for_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_coverage_for_file(data_from_redis, hash)
              return if data_from_redis.empty?
      
              file = data_from_redis[FILE_KEY]
              return unless file_hash(file) == data_from_redis[FILE_HASH]
      Severity: Minor
      Found in lib/coverband/adapters/hash_redis_store.rb - 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

      Method save_report has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def save_report
              reported_time = Time.now.to_i
              if @views_to_record.any?
                relative_views = @views_to_record.map! do |view|
                  roots.each do |root|
      Severity: Minor
      Found in lib/coverband/collectors/view_tracker_service.rb - 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

      Severity
      Category
      Status
      Source
      Language