Showing 83 of 83 total issues

File parser.rb has 1095 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "strscan"

require_relative "input_record_separator"
require_relative "row"
require_relative "table"
Severity: Major
Found in lib/csv/parser.rb - About 2 days to fix

    File csv.rb has 648 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "forwardable"
    require "date"
    require "stringio"
    
    require_relative "csv/fields_converter"
    Severity: Major
    Found in lib/csv.rb - About 1 day to fix

      Class CSV has 63 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class CSV
      
        # The error thrown when the parser encounters illegal CSV formatting.
        class MalformedCSVError < RuntimeError
          attr_reader :line_number
      Severity: Major
      Found in lib/csv.rb - About 1 day to fix

        Class Parser has 54 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Parser
            #
            # A CSV::Parser is m17n aware. The parser works in the Encoding of the IO
            # or String object being read from or written to. Your data is never transcoded
            # (unless you ask Ruby to transcode it for you) and will literally be parsed in
        Severity: Major
        Found in lib/csv/parser.rb - About 7 hrs to fix

          Method parse_quoted_column_value has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_quoted_column_value
                quotes = @scanner.scan_all(@quotes)
                return nil unless quotes
          
                @quoted_column_value = true
          Severity: Minor
          Found in lib/csv/parser.rb - About 5 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 parse_quotable_robust has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_quotable_robust(&block)
                row = []
                quoted_fields = []
                skip_needless_lines
                start_row
          Severity: Minor
          Found in lib/csv/parser.rb - About 5 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 convert has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

              def convert(fields, headers, lineno, quoted_fields)
                return fields unless need_convert?
          
                fields.collect.with_index do |field, index|
                  if field.nil?
          Severity: Minor
          Found in lib/csv/fields_converter.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 each_line has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

                def each_line(row_separator)
                  return enum_for(__method__, row_separator) unless block_given?
                  buffer = nil
                  input = @scanner.rest
                  position = @scanner.pos
          Severity: Minor
          Found in lib/csv/parser.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 parse_quotable_loose has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_quotable_loose(&block)
                @scanner.keep_start
                @scanner.each_line(@row_separator) do |line|
                  if @skip_lines and skip_line?(line)
                    @scanner.keep_drop
          Severity: Minor
          Found in lib/csv/parser.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 resolve_row_separator has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              def resolve_row_separator(separator)
                if separator == :auto
                  cr = "\r".encode(@encoding)
                  lf = "\n".encode(@encoding)
                  if @input.is_a?(StringIO)
          Severity: Minor
          Found in lib/csv/parser.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 parse_column_value has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_column_value
                if @liberal_parsing
                  quoted_value = parse_quoted_column_value
                  if quoted_value
                    @scanner.scan_all(@strip_value) if @strip_value
          Severity: Minor
          Found in lib/csv/parser.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 []= has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              def []=(index_or_header, value)
                if @mode == :row or  # by index
                   (@mode == :col_or_row and index_or_header.is_a? Integer)
                  if value.is_a? Array
                    @table[index_or_header] = Row.new(headers, value)
          Severity: Minor
          Found in lib/csv/table.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 fields has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              def fields(*headers_and_or_indices)
                if headers_and_or_indices.empty?  # return all fields--no arguments
                  @row.map(&:last)
                else                              # or work like values_at()
                  all = []
          Severity: Minor
          Found in lib/csv/row.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 parse_no_quote has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_no_quote(&block)
                @scanner.each_line(@row_separator) do |line|
                  next if @skip_lines and skip_line?(line)
                  original_line = line
                  line = line.delete_suffix(@row_separator)
          Severity: Minor
          Found in lib/csv/parser.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 read_chunk has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

                def read_chunk
                  return false if @last_scanner
          
                  adjust_last_keep
          
          
          Severity: Minor
          Found in lib/csv/parser.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 parse_quotable_robust has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def parse_quotable_robust(&block)
                row = []
                quoted_fields = []
                skip_needless_lines
                start_row
          Severity: Major
          Found in lib/csv/parser.rb - About 2 hrs to fix

            Class Row has 24 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Row
                # :call-seq:
                #   CSV::Row.new(headers, fields, header_row = false) -> csv_row
                #
                # Returns the new \CSV::Row instance constructed from
            Severity: Minor
            Found in lib/csv/row.rb - About 2 hrs to fix

              Method initialize has 65 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def initialize(data,
                               col_sep: ",",
                               row_sep: :auto,
                               quote_char: '"',
                               field_size_limit: nil,
              Severity: Major
              Found in lib/csv.rb - About 2 hrs to fix

                Method parse_unquoted_column_value has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    def parse_unquoted_column_value
                      value = @scanner.scan_all(@unquoted_value)
                      return nil unless value
                
                      @unquoted_column_value = true
                Severity: Minor
                Found in lib/csv/parser.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 parse has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    def parse(&block)
                      return to_enum(__method__) unless block_given?
                
                      if @return_headers and @headers and @raw_headers
                        headers = Row.new(@headers, @raw_headers, true)
                Severity: Minor
                Found in lib/csv/parser.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

                Severity
                Category
                Status
                Source
                Language