Showing 79 of 83 total issues

Method detect_row_separator has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def detect_row_separator(sample, cr, lf)
      lf_index = sample.index(lf)
      if lf_index
        cr_index = sample[0, lf_index].index(cr)
      else
Severity: Minor
Found in lib/csv/parser.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 inspect has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def inspect
    str = ["#<", self.class.to_s, " io_type:"]
    # show type of wrapped IO
    if    @io == $stdout then str << "$stdout"
    elsif @io == $stdin  then str << "$stdin"
Severity: Minor
Found in lib/csv.rb - About 1 hr to fix

    Method keep_back has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def keep_back
            # trace(__method__, :start)
            scanner, start, buffer = @keeps.pop
            if buffer
              # trace(__method__, :rescan, start, buffer)
    Severity: Minor
    Found in lib/csv/parser.rb - About 1 hr to fix

      Method prepare_strip has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def prepare_strip
            @strip = @options[:strip]
            @escaped_strip = nil
            @strip_value = nil
            @rstrip_value = nil
      Severity: Minor
      Found in lib/csv/parser.rb - About 1 hr to fix

        Method []= has 30 lines of code (exceeds 25 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 1 hr to fix

          Method resolve_row_separator has 28 lines of code (exceeds 25 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 1 hr to fix

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

                def quote(field, i)
                  if @force_quotes
                    quote_field(field)
                  elsif @force_quotes_fields and @force_quotes_fields[i]
                    quote_field(field)
            Severity: Minor
            Found in lib/csv/writer.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 prepare_output has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def prepare_output
                  @output_encoding = nil
                  return unless @output.is_a?(StringIO)
            
                  output_encoding = @output.internal_encoding || @output.external_encoding
            Severity: Minor
            Found in lib/csv/writer.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 parse_column_value has 27 lines of code (exceeds 25 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 1 hr to fix

              Method prepare_format has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def prepare_format
                    @column_separator = @options[:column_separator].to_s.encode(@encoding)
                    row_separator = @options[:row_separator]
                    if row_separator == :auto
                      @row_separator = InputRecordSeparator.value.encode(@encoding)
              Severity: Minor
              Found in lib/csv/writer.rb - About 1 hr to fix

                Method parse_no_quote has 27 lines of code (exceeds 25 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 1 hr to fix

                  Method build_scanner has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def build_scanner
                          string = nil
                          if @samples.empty? and @input.is_a?(StringIO)
                            string = @input.read
                          elsif @samples.size == 1 and
                  Severity: Minor
                  Found in lib/csv/parser.rb - About 1 hr to fix

                    Method skip_needless_lines has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def skip_needless_lines
                          return unless @skip_lines
                    
                          until @scanner.eos?
                            @scanner.keep_start
                    Severity: Minor
                    Found in lib/csv/parser.rb - About 55 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 prepare_force_quotes_fields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def prepare_force_quotes_fields(force_quotes)
                          @force_quotes_fields = {}
                          force_quotes.each do |name_or_index|
                            case name_or_index
                            when Integer
                    Severity: Minor
                    Found in lib/csv/writer.rb - About 55 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 adjust_last_keep has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def adjust_last_keep
                            # trace(__method__, :start)
                    
                            keep = @keeps.last
                            # trace(__method__, :done, :empty) if keep.nil?
                    Severity: Minor
                    Found in lib/csv/parser.rb - About 55 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 prepare_strip has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def prepare_strip
                          @strip = @options[:strip]
                          @escaped_strip = nil
                          @strip_value = nil
                          @rstrip_value = nil
                    Severity: Minor
                    Found in lib/csv/parser.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

                    Avoid deeply nested control flow statements.
                    Open

                                if liberal_parsing? and (new_line = @scanner.check(@line_end))
                                  message =
                                    "Illegal end-of-line sequence outside of a quoted field " +
                                    "<#{new_line.inspect}>"
                                else
                    Severity: Major
                    Found in lib/csv/parser.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                elsif @unquoted_column_value and
                                      (new_line = @scanner.scan(@line_end))
                                  ignore_broken_line
                                  message = "Unquoted fields do not allow new line " +
                                            "<#{new_line.inspect}>"
                      Severity: Major
                      Found in lib/csv/parser.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      if quoted_value.empty? # %Q{""...} case
                                        return @quote_character + unquoted_value
                                      end
                        Severity: Major
                        Found in lib/csv/parser.rb - About 45 mins to fix

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

                              def each(&block)
                                return enum_for(__method__) { @mode == :col ? headers.size : size } unless block_given?
                          
                                if @mode == :col
                                  headers.each.with_index do |header, i|
                          Severity: Minor
                          Found in lib/csv/table.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

                          Severity
                          Category
                          Status
                          Source
                          Language