Showing 195 of 195 total issues
%q
-literals should be delimited by (
and )
. Open
s.summary = %q{Easily view SNMP tables.}
- Read upRead up
- Exclude checks
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)
Avoid comma after the last item of a hash. Open
formatter: SNMPTableViewer::Formatter::Table,
- Read upRead up
- Exclude checks
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
]
Use %w
or %W
for an array of words. Open
'ifTable' => ['Index', 'Descr', 'Type', 'Mtu', 'Speed', 'PhysAddress', 'AdminStatus', 'OperStatus', 'LastChange', 'InOctets', 'InUcastPkts', 'InNUcastkts', 'InDiscards', 'InErrors', 'InUnknownPrortos', 'OutOctets', 'OutUcastPkts', 'OutNUcastPkts', 'OutDiscards', 'OutErrors', 'OutQLen', 'Specific'],
- Read upRead up
- Exclude checks
This cop can check for array literals made up of word-like strings, that are not using the %w() syntax.
Alternatively, it can check for uses of the %w() syntax, in projects which do not want to include that syntax.
Configuration option: MinSize
If set, arrays with fewer elements than this value will not trigger the
cop. For example, a MinSize
of 3
will not enforce a style on an
array of 2 or fewer elements.
Example: EnforcedStyle: percent (default)
# good
%w[foo bar baz]
# bad
['foo', 'bar', 'baz']
Example: EnforcedStyle: brackets
# good
['foo', 'bar', 'baz']
# bad
%w[foo bar baz]
Do not place comments on the same line as the end
keyword. Open
end # module SNMPTableViewer
- Read upRead up
- Exclude checks
This cop checks for comments put on the same line as some keywords.
These keywords are: begin
, class
, def
, end
, module
.
Note that some comments (such as :nodoc:
and rubocop:disable
) are
allowed.
Example:
# bad
if condition
statement
end # end if
# bad
class X # comment
statement
end
# bad
def x; end # comment
# good
if condition
statement
end
# good
class X # :nodoc:
y
end
Use 2 (not 4) spaces for indentation. Open
@headings = headings
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Extra empty line detected at module body beginning. Open
# Parent class for converters. Which take data and perform sometranslations/conversions to it..
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of modules match the configuration.
Example: EnforcedStyle: empty_lines
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
module Foo
module Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
module Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
module Foo
def bar
# ...
end
end
Extra empty line detected at module body end. Open
end # module SNMPTableViewer
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of modules match the configuration.
Example: EnforcedStyle: empty_lines
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
module Foo
module Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
module Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
module Foo
def bar
# ...
end
end
Indent when
as deep as case
. Open
when 'integer', 'integer32', 'uinteger32', 'gauge32', 'counter32', 'counter64'
- Read upRead up
- Exclude checks
This cop checks how the whens of a case expression are indented in relation to its case or end keyword.
It will register a separate offense for each misaligned when.
Example:
# If Layout/EndAlignment is set to keyword style (default)
# *case* and *end* should always be aligned to same depth,
# and therefore *when* should always be aligned to both -
# regardless of configuration.
# bad for all styles
case n
when 0
x * 2
else
y / 3
end
# good for all styles
case n
when 0
x * 2
else
y / 3
end
Example: EnforcedStyle: case (default)
# if EndAlignment is set to other style such as
# start_of_line (as shown below), then *when* alignment
# configuration does have an effect.
# bad
a = case n
when 0
x * 2
else
y / 3
end
# good
a = case n
when 0
x * 2
else
y / 3
end
Example: EnforcedStyle: end
# bad
a = case n
when 0
x * 2
else
y / 3
end
# good
a = case n
when 0
x * 2
else
y / 3
end
Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency coveralls
should appear before rb-inotify
. Open
s.add_development_dependency 'coveralls', '~> 0.7'
- Read upRead up
- Exclude checks
Dependencies in the gemspec should be alphabetically sorted.
Example:
# bad
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'
# good
spec.add_dependency 'rspec'
spec.add_dependency 'rubocop'
# good
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'
# bad
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'
# good
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'
# good
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'
# bad
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'
# good
spec.add_runtime_dependency 'rspec'
spec.add_runtime_dependency 'rubocop'
# good
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'
Extra blank line detected. Open
opts.separator "\nTable formatter options:"
- Read upRead up
- Exclude checks
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. [127/80] Open
opts.on('-x PRIV_PROTOCOL', '--priv-protocol PRIV_PROTOCOL', 'Privacy protocol to use (DES|AES) (default DES).') do |value|
- Exclude checks
Use nested module/class definitions instead of compact style. Open
class Formatter::CSV < Formatter
- Read upRead up
- Exclude checks
This cop checks the style of children definitions at classes and modules. Basically there are two different styles:
Example: EnforcedStyle: nested (default)
# good
# have each child on its own line
class Foo
class Bar
end
end
Example: EnforcedStyle: compact
# good
# combine definitions as much as possible
class Foo::Bar
end
The compact style is only forced for classes/modules with one child.
Omit the parentheses in defs when the method doesn't accept any arguments. Open
def output()
- Read upRead up
- Exclude checks
This cop checks for parentheses in the definition of a method, that does not take any arguments. Both instance and class/singleton methods are checked.
Example:
# bad
def foo()
# does a thing
end
# good
def foo
# does a thing
end
# also good
def foo() does_a_thing end
Example:
# bad
def Baz.foo()
# does a thing
end
# good
def Baz.foo
# does a thing
end
Omit the parentheses in defs when the method doesn't accept any arguments. Open
def output()
- Read upRead up
- Exclude checks
This cop checks for parentheses in the definition of a method, that does not take any arguments. Both instance and class/singleton methods are checked.
Example:
# bad
def foo()
# does a thing
end
# good
def foo
# does a thing
end
# also good
def foo() does_a_thing end
Example:
# bad
def Baz.foo()
# does a thing
end
# good
def Baz.foo
# does a thing
end
Line is too long. [125/80] Open
# @param data [Array<Array<#to_s>>] A two dimensional array containing objects in each cell (at 'address' data[row][col])
- Exclude checks
Line is too long. [81/80] Open
# @param headings [Array<String, #to_s>] An array of headings for each column
- Exclude checks
Line is too long. [97/80] Open
# Parent class for converters. Which take data and perform sometranslations/conversions to it..
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
VERSION = "0.0.6"
- Read upRead up
- Exclude checks
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"
Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency guard-rspec
should appear before rspec
. Open
s.add_development_dependency 'guard-rspec', '~> 4.2', '>= 4.2.5'
- Read upRead up
- Exclude checks
Dependencies in the gemspec should be alphabetically sorted.
Example:
# bad
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'
# good
spec.add_dependency 'rspec'
spec.add_dependency 'rubocop'
# good
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'
# bad
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'
# good
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'
# good
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'
# bad
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'
# good
spec.add_runtime_dependency 'rspec'
spec.add_runtime_dependency 'rubocop'
# good
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'
Extra blank line detected. Open
opts.separator "\nSNMP common options:"
- Read upRead up
- Exclude checks
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