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 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.

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.

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.

    Line is too long. [152/80]
    Open

        opts.on('--converter CONVERTER', String, "A converter to run on the data before formatting (#{SNMPTableViewer::CONVERTERS.keys.join('|')}).") do |v|
    Severity: Minor
    Found in bin/table-from-snmp by rubocop

    Avoid comma after the last item of a hash.
    Open

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

    This cop checks for trailing comma in array and hash literals.

    Example: EnforcedStyleForMultiline: consistent_comma

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1, 2,
      3,
    ]
    
    # good
    a = [
      1,
      2,
    ]

    Example: EnforcedStyleForMultiline: comma

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1,
      2,
    ]

    Example: EnforcedStyleForMultiline: no_comma (default)

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1,
      2
    ]

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

      desc "Run the Travis CI tests"
    Severity: Minor
    Found in Rakefile by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    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

    Line is too long. [103/80]
    Open

        opts.on('-c COMMUNITY', '--comunity COMMUNITY', 'SNMP comunity (default "public").') do |community|
    Severity: Minor
    Found in bin/table-from-snmp by rubocop

    Line is too long. [111/80]
    Open

        opts.on('-X PRIV_PASSWORD', '--priv-password PRIV_PASSWORD', 'Privacy password to use.', String) do |value|
    Severity: Minor
    Found in bin/table-from-snmp by rubocop

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

        opts.banner = "Usage: table-from-snmp [options]"
    Severity: Minor
    Found in bin/table-from-snmp by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"
    Severity
    Category
    Status
    Source
    Language