robertgauld/snmp_table_viewer

View on GitHub

Showing 195 of 195 total issues

Method has too many lines. [88/10]
Open

def parse_command_line
  options = {
    SNMPTableViewer::Formatter::Table => {
      transpose: false,
    },
Severity: Minor
Found in bin/table-from-snmp by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for parse_command_line is too high. [69.29/15]
Open

def parse_command_line
  options = {
    SNMPTableViewer::Formatter::Table => {
      transpose: false,
    },
Severity: Minor
Found in bin/table-from-snmp by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [32/10]
Open

    def self.from_array(data_in)
      data_out = Array.new
      regexp_general = Regexp.compile(/\A(?:iso)?[\.0-9]+\.([0-9]+)\.([0-9]+)\s+=\s+([A-Za-z0-9 \-]+):\s+(.+)\Z/)
      regexp_nodata = Regexp.compile(/\A(?:iso)?[\.0-9]+\.([0-9]+)\.([0-9]+)\s+=\s+""\Z/)
      data_in.each.with_index do |line, index|
Severity: Minor
Found in lib/snmp_table_viewer/fetcher.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [32/10]
Open

def parse_command_line
  options = {
    SNMPTableViewer::Formatter::Table => {
      transpose: false,
    },
Severity: Minor
Found in bin/table-from-stdin by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for from_array is too high. [36.36/15]
Open

    def self.from_array(data_in)
      data_out = Array.new
      regexp_general = Regexp.compile(/\A(?:iso)?[\.0-9]+\.([0-9]+)\.([0-9]+)\s+=\s+([A-Za-z0-9 \-]+):\s+(.+)\Z/)
      regexp_nodata = Regexp.compile(/\A(?:iso)?[\.0-9]+\.([0-9]+)\.([0-9]+)\s+=\s+""\Z/)
      data_in.each.with_index do |line, index|
Severity: Minor
Found in lib/snmp_table_viewer/fetcher.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Block has too many lines. [58/25]
Open

  parser = OptionParser.new do |opts|
    opts.banner = "Usage: table-from-snmp [options]"

    opts.on('-h', '--help', '-?', 'Prints this help.') do
      puts opts
Severity: Minor
Found in bin/table-from-snmp by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Assignment Branch Condition size for parse_command_line is too high. [27.22/15]
Open

def parse_command_line
  options = {
    SNMPTableViewer::Formatter::Table => {
      transpose: false,
    },
Severity: Minor
Found in bin/table-from-stdin by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [15/10]
Open

    def output(transpose: false)
      use_headings = @headings.size > 0
      data = @data

      if transpose

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for from_array is too high. [10/6]
Open

    def self.from_array(data_in)
      data_out = Array.new
      regexp_general = Regexp.compile(/\A(?:iso)?[\.0-9]+\.([0-9]+)\.([0-9]+)\s+=\s+([A-Za-z0-9 \-]+):\s+(.+)\Z/)
      regexp_nodata = Regexp.compile(/\A(?:iso)?[\.0-9]+\.([0-9]+)\.([0-9]+)\s+=\s+""\Z/)
      data_in.each.with_index do |line, index|
Severity: Minor
Found in lib/snmp_table_viewer/fetcher.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method from_array has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def self.from_array(data_in)
      data_out = Array.new
      regexp_general = Regexp.compile(/\A(?:iso)?[\.0-9]+\.([0-9]+)\.([0-9]+)\s+=\s+([A-Za-z0-9 \-]+):\s+(.+)\Z/)
      regexp_nodata = Regexp.compile(/\A(?:iso)?[\.0-9]+\.([0-9]+)\.([0-9]+)\s+=\s+""\Z/)
      data_in.each.with_index do |line, index|
Severity: Minor
Found in lib/snmp_table_viewer/fetcher.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 from_array has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.from_array(data_in)
      data_out = Array.new
      regexp_general = Regexp.compile(/\A(?:iso)?[\.0-9]+\.([0-9]+)\.([0-9]+)\s+=\s+([A-Za-z0-9 \-]+):\s+(.+)\Z/)
      regexp_nodata = Regexp.compile(/\A(?:iso)?[\.0-9]+\.([0-9]+)\.([0-9]+)\s+=\s+""\Z/)
      data_in.each.with_index do |line, index|
Severity: Minor
Found in lib/snmp_table_viewer/fetcher.rb - About 1 hr to fix

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

        def output(transpose: false)
          use_headings = @headings.size > 0
          data = @data
    
          if transpose
    Severity: Minor
    Found in lib/snmp_table_viewer/formatter/table.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

    Block has too many lines. [26/25]
    Open

          data_in.each.with_index do |line, index|
            # Try to get a match on the various valid frmats of line
            match = line.match(regexp_general)
            match ||= line.match(regexp_nodata)
            if match.nil?
    Severity: Minor
    Found in lib/snmp_table_viewer/fetcher.rb by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Prefer $LOAD_PATH over $:.
    Open

    $:.push File.expand_path(File.join('..', 'lib'), __FILE__)
    Severity: Minor
    Found in snmp_table_viewer.gemspec by rubocop

    %q-literals should be delimited by ( and ).
    Open

      s.summary     = %q{Easily view SNMP tables.}
    Severity: Minor
    Found in snmp_table_viewer.gemspec by rubocop

    This cop enforces the consistent usage of %-literal delimiters.

    Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

    Example:

    # Style/PercentLiteralDelimiters:
    #   PreferredDelimiters:
    #     default: '[]'
    #     '%i':    '()'
    
    # good
    %w[alpha beta] + %i(gamma delta)
    
    # bad
    %W(alpha #{beta})
    
    # bad
    %I(alpha beta)

    Use %q only for strings that contain both single quotes and double quotes.
    Open

      s.description = %q{Easily view SNMP tables in a variety of different formats including as a table in the terminal, json or csv.}
    Severity: Minor
    Found in snmp_table_viewer.gemspec by rubocop

    Extra blank line detected.
    Open

    
        opts.separator "\nSNMP version 1 and 2 options:"
    Severity: Minor
    Found in bin/table-from-snmp by rubocop

    This cops checks for two or more consecutive blank lines.

    Example:

    # bad - It has two empty lines.
    some_method
    # one empty line
    # two empty lines
    some_method
    
    # good
    some_method
    # one empty line
    some_method

    %q-literals should be delimited by ( and ).
    Open

      s.description = %q{Easily view SNMP tables in a variety of different formats including as a table in the terminal, json or csv.}
    Severity: Minor
    Found in snmp_table_viewer.gemspec by rubocop

    This cop enforces the consistent usage of %-literal delimiters.

    Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

    Example:

    # Style/PercentLiteralDelimiters:
    #   PreferredDelimiters:
    #     default: '[]'
    #     '%i':    '()'
    
    # good
    %w[alpha beta] + %i(gamma delta)
    
    # bad
    %W(alpha #{beta})
    
    # bad
    %I(alpha beta)

    Extra blank line detected.
    Open

    
    
    
    Severity: Minor
    Found in bin/table-from-snmp by rubocop

    This cops checks for two or more consecutive blank lines.

    Example:

    # bad - It has two empty lines.
    some_method
    # one empty line
    # two empty lines
    some_method
    
    # good
    some_method
    # one empty line
    some_method

    Extra empty line detected at block body end.
    Open

    
      end # create parser
    Severity: Minor
    Found in bin/table-from-stdin by rubocop

    This cops checks if empty lines around the bodies of blocks match the configuration.

    Example: EnforcedStyle: empty_lines

    # good
    
    foo do |bar|
    
      # ...
    
    end

    Example: EnforcedStyle: noemptylines (default)

    # good
    
    foo do |bar|
      # ...
    end
    Severity
    Category
    Status
    Source
    Language