9troisquarts/ntq-excelsior

View on GitHub

Showing 211 of 211 total issues

Assignment Branch Condition size for add_sheet_content is too high. [<10, 54, 26> 60.76/17]
Open

    def add_sheet_content(content, wb_styles, sheet)
      content[:rows].each_with_index do |row, index|
        row_style = []
        if row[:styles].is_a?(Array) && row[:styles].any?
          row[:styles].each do |style|
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

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 and https://en.wikipedia.org/wiki/ABC_Software_Metric.

Interpreting ABC size:

  • <= 17 satisfactory
  • 18..30 unsatisfactory
  • > 30 dangerous

You can have repeated "attributes" calls count as a single "branch". For this purpose, attributes are any method with no argument; no attempt is meant to distinguish actual attr_reader from other methods.

Example: CountRepeatedAttributes: false (default is true)

# `model` and `current_user`, referenced 3 times each,
 # are each counted as only 1 branch each if
 # `CountRepeatedAttributes` is set to 'false'

 def search
   @posts = model.active.visible_by(current_user)
             .search(params[:q])
   @posts = model.some_process(@posts, current_user)
   @posts = model.another_process(@posts, current_user)

   render 'pages/search/page'
 end

This cop also takes into account AllowedMethods (defaults to []) And AllowedPatterns (defaults to [])

Group together all attr_accessor attributes.
Open

    attr_accessor :data
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

Checks for grouping of accessors in class and module bodies. By default it enforces accessors to be placed in grouped declarations, but it can be configured to enforce separating them in multiple declarations.

NOTE: If there is a method call before the accessor method it is always allowed as it might be intended like Sorbet.

Example: EnforcedStyle: grouped (default)

# bad
class Foo
  attr_reader :bar
  attr_reader :bax
  attr_reader :baz
end

# good
class Foo
  attr_reader :bar, :bax, :baz
end

# good
class Foo
  # may be intended comment for bar.
  attr_reader :bar

  sig { returns(String) }
  attr_reader :bax

  may_be_intended_annotation :baz
  attr_reader :baz
end

Example: EnforcedStyle: separated

# bad
class Foo
  attr_reader :bar, :baz
end

# good
class Foo
  attr_reader :bar
  attr_reader :baz
end

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

      if value.is_a?(String)
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

Checks for if and unless statements that would fit on one line if written as modifier if/unless. The cop also checks for modifier if/unless lines that exceed the maximum line length.

The maximum line length is configured in the Layout/LineLength cop. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop.

One-line pattern matching is always allowed. To ensure that there are few cases where the match variable is not used, and to prevent oversights. The variable x becomes undefined and raises NameError when the following example is changed to the modifier form:

if [42] in [x]
  x # `x` is undefined when using modifier form.
end

NOTE: It is allowed when defined? argument has an undefined value, because using the modifier form causes the following incompatibility:

unless defined?(undefined_foo)
  undefined_foo = 'default_value'
end
undefined_foo # => 'default_value'

undefined_bar = 'default_value' unless defined?(undefined_bar)
undefined_bar # => nil

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

do_something_with_a_long_name(arg) if long_condition_that_prevents_code_fit_on_single_line

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

if long_condition_that_prevents_code_fit_on_single_line
  do_something_with_a_long_name(arg)
end

if short_condition # a long comment that makes it too long if it were just a single line
  do_something
end

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Open

        format_code: 'dd-mm-yyyy'
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb 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"

Avoid comma after the last item of a hash.
Open

        showInputMessage: list_config[:show_input_message] || false,
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

Checks for trailing comma in hash literals. The configuration options are:

  • consistent_comma: Requires a comma after the last item of all non-empty, multiline hash literals.
  • comma: Requires a comma after the last item in a hash, but only when each item is on its own line.
  • no_comma: Does not require a comma after the last item in a hash

Example: EnforcedStyleForMultiline: consistent_comma

# bad
a = { foo: 1, bar: 2, }

# good
a = { foo: 1, bar: 2 }

# good
a = {
  foo: 1, bar: 2,
  qux: 3,
}

# good
a = {
  foo: 1, bar: 2, qux: 3,
}

# good
a = {
  foo: 1,
  bar: 2,
}

Example: EnforcedStyleForMultiline: comma

# bad
a = { foo: 1, bar: 2, }

# good
a = { foo: 1, bar: 2 }

# bad
a = {
  foo: 1, bar: 2,
  qux: 3,
}

# good
a = {
  foo: 1, bar: 2,
  qux: 3
}

# bad
a = {
  foo: 1, bar: 2, qux: 3,
}

# good
a = {
  foo: 1, bar: 2, qux: 3
}

# good
a = {
  foo: 1,
  bar: 2,
}

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
a = { foo: 1, bar: 2, }

# good
a = {
  foo: 1,
  bar: 2
}

Assignment Branch Condition size for detect_header_scheme is too high. [<8, 30, 14> 34.06/17]
Open

    def detect_header_scheme
      return @header_scheme if @header_scheme

      @header_scheme = {}
      # Read the first line of file (not header)
Severity: Minor
Found in lib/ntq_excelsior/importer.rb by rubocop

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 and https://en.wikipedia.org/wiki/ABC_Software_Metric.

Interpreting ABC size:

  • <= 17 satisfactory
  • 18..30 unsatisfactory
  • > 30 dangerous

You can have repeated "attributes" calls count as a single "branch". For this purpose, attributes are any method with no argument; no attempt is meant to distinguish actual attr_reader from other methods.

Example: CountRepeatedAttributes: false (default is true)

# `model` and `current_user`, referenced 3 times each,
 # are each counted as only 1 branch each if
 # `CountRepeatedAttributes` is set to 'false'

 def search
   @posts = model.active.visible_by(current_user)
             .search(params[:q])
   @posts = model.some_process(@posts, current_user)
   @posts = model.another_process(@posts, current_user)

   render 'pages/search/page'
 end

This cop also takes into account AllowedMethods (defaults to []) And AllowedPatterns (defaults to [])

Modifier form of if makes the line too long.
Open

      @header_scheme[self.class.primary_key.to_s] = self.class.primary_key.to_s if self.class.primary_key && !self.class.schema[self.class.primary_key.to_sym]
Severity: Minor
Found in lib/ntq_excelsior/importer.rb by rubocop

Checks for if and unless statements that would fit on one line if written as modifier if/unless. The cop also checks for modifier if/unless lines that exceed the maximum line length.

The maximum line length is configured in the Layout/LineLength cop. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop.

One-line pattern matching is always allowed. To ensure that there are few cases where the match variable is not used, and to prevent oversights. The variable x becomes undefined and raises NameError when the following example is changed to the modifier form:

if [42] in [x]
  x # `x` is undefined when using modifier form.
end

NOTE: It is allowed when defined? argument has an undefined value, because using the modifier form causes the following incompatibility:

unless defined?(undefined_foo)
  undefined_foo = 'default_value'
end
undefined_foo # => 'default_value'

undefined_bar = 'default_value' unless defined?(undefined_bar)
undefined_bar # => nil

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

do_something_with_a_long_name(arg) if long_condition_that_prevents_code_fit_on_single_line

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

if long_condition_that_prevents_code_fit_on_single_line
  do_something_with_a_long_name(arg)
end

if short_condition # a long comment that makes it too long if it were just a single line
  do_something
end

Use spreadsheet_data.size.positive? instead of spreadsheet_data.size > 0.
Open

        raise 'File is inconsistent, please check you have data in it or check for invalid characters in headers like , / ; etc...' unless spreadsheet_data.size > 0
Severity: Minor
Found in lib/ntq_excelsior/importer.rb by rubocop

Checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. This cop can also be configured to do the reverse.

This cop can be customized allowed methods with AllowedMethods. By default, there are no methods to allowed.

This cop disregards #nonzero? as its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

This cop allows comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Integer polymorphic.

Safety:

This cop is unsafe because it cannot be guaranteed that the receiver defines the predicates or can be compared to a number, which may lead to a false positive for non-standard classes.

Example: EnforcedStyle: predicate (default)

# bad
foo == 0
0 > foo
bar.baz > 0

# good
foo.zero?
foo.negative?
bar.baz.positive?

Example: EnforcedStyle: comparison

# bad
foo.zero?
foo.negative?
bar.baz.positive?

# good
foo == 0
0 > foo
bar.baz > 0

Example: AllowedMethods: [] (default) with EnforcedStyle: predicate

# bad
foo == 0
0 > foo
bar.baz > 0

Example: AllowedMethods: [==] with EnforcedStyle: predicate

# good
foo == 0

# bad
0 > foo
bar.baz > 0

Example: AllowedPatterns: [] (default) with EnforcedStyle: comparison

# bad
foo.zero?
foo.negative?
bar.baz.positive?

Example: AllowedPatterns: ['zero'] with EnforcedStyle: predicate

# good
# bad
foo.zero?

# bad
foo.negative?
bar.baz.positive?

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Open

require 'caxlsx'

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"

Modifier form of unless makes the line too long.
Open

        raise 'File is inconsistent, please check you have data in it or check for invalid characters in headers like , / ; etc...' unless spreadsheet_data.size > 0
Severity: Minor
Found in lib/ntq_excelsior/importer.rb by rubocop

Checks for if and unless statements that would fit on one line if written as modifier if/unless. The cop also checks for modifier if/unless lines that exceed the maximum line length.

The maximum line length is configured in the Layout/LineLength cop. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop.

One-line pattern matching is always allowed. To ensure that there are few cases where the match variable is not used, and to prevent oversights. The variable x becomes undefined and raises NameError when the following example is changed to the modifier form:

if [42] in [x]
  x # `x` is undefined when using modifier form.
end

NOTE: It is allowed when defined? argument has an undefined value, because using the modifier form causes the following incompatibility:

unless defined?(undefined_foo)
  undefined_foo = 'default_value'
end
undefined_foo # => 'default_value'

undefined_bar = 'default_value' unless defined?(undefined_bar)
undefined_bar # => nil

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

do_something_with_a_long_name(arg) if long_condition_that_prevents_code_fit_on_single_line

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

if long_condition_that_prevents_code_fit_on_single_line
  do_something_with_a_long_name(arg)
end

if short_condition # a long comment that makes it too long if it were just a single line
  do_something
end

Missing top-level documentation comment for class NtqExcelsior::MultiWorkbookExporter.
Open

  class MultiWorkbookExporter

Checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, constant definitions or constant visibility declarations.

The documentation requirement is annulled if the class or module has a #:nodoc: comment next to it. Likewise, #:nodoc: all does the same for all its children.

Example:

# bad
class Person
  # ...
end

module Math
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

# allowed
  # Class without body
  class Person
  end

  # Namespace - A namespace can be a class or a module
  # Containing a class
  module Namespace
    # Description/Explanation of Person class
    class Person
      # ...
    end
  end

  # Containing constant visibility declaration
  module Namespace
    class Private
    end

    private_constant :Private
  end

  # Containing constant definition
  module Namespace
    Public = Class.new
  end

  # Macro calls
  module Namespace
    extend Foo
  end

Example: AllowedConstants: ['ClassMethods']

# good
 module A
   module ClassMethods
     # ...
   end
  end

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Open

require 'ntq_excelsior/importer'
Severity: Minor
Found in lib/ntq_excelsior.rb 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"

Expected 1 empty line between method definitions; found 0.
Open

      def styles(value = nil)
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

Checks whether class/module/method definitions are separated by one or more empty lines.

NumberOfEmptyLines can be an integer (default is 1) or an array (e.g. [1, 2]) to specify a minimum and maximum number of empty lines permitted.

AllowAdjacentOneLineDefs configures whether adjacent one-line definitions are considered an offense.

Example: EmptyLineBetweenMethodDefs: true (default)

# checks for empty lines between method definitions.

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Example: EmptyLineBetweenClassDefs: true (default)

# checks for empty lines between class definitions.

# bad
class A
end
class B
end
def b
end

Example:

# good
class A
end

class B
end

def b
end

Example: EmptyLineBetweenModuleDefs: true (default)

# checks for empty lines between module definitions.

# bad
module A
end
module B
end
def b
end

Example:

# good
module A
end

module B
end

def b
end

Example: AllowAdjacentOneLineDefs: true (default)

# good
class ErrorA < BaseError; end
class ErrorB < BaseError; end
class ErrorC < BaseError; end

# good
class ErrorA < BaseError; end

class ErrorB < BaseError; end

class ErrorC < BaseError; end

Example: AllowAdjacentOneLineDefs: false

# bad
class ErrorA < BaseError; end
class ErrorB < BaseError; end
class ErrorC < BaseError; end

# good
class ErrorA < BaseError; end

class ErrorB < BaseError; end

class ErrorC < BaseError; end

Tab detected in indentation.
Open

        def initialize(data)
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

Checks that the indentation method is consistent. Either tabs only or spaces only are used for indentation.

Example: EnforcedStyle: spaces (default)

# bad
# This example uses a tab to indent bar.
def foo
  bar
end

# good
# This example uses spaces to indent bar.
def foo
  bar
end

Example: EnforcedStyle: tabs

# bad
# This example uses spaces to indent bar.
def foo
  bar
end

# good
# This example uses a tab to indent bar.
def foo
  bar
end

Space missing to the left of {.
Open

      columns_with_children = columns.select{ |c| c[:children] && c[:children].any? }
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

Checks that block braces have or don't have a space before the opening brace depending on configuration.

Example: EnforcedStyle: space (default)

# bad
foo.map{ |a|
  a.bar.to_s
}

# good
foo.map { |a|
  a.bar.to_s
}

Example: EnforcedStyle: no_space

# bad
foo.map { |a|
  a.bar.to_s
}

# good
foo.map{ |a|
  a.bar.to_s
}

Example: EnforcedStyleForEmptyBraces: space (default)

# bad
7.times{}

# good
7.times {}

Example: EnforcedStyleForEmptyBraces: no_space

# bad
7.times {}

# good
7.times{}

Use next to skip iteration.
Open

        if row[:merge_cells]
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

Use next to skip iteration instead of a condition at the end.

Example: EnforcedStyle: skipmodifierifs (default)

# bad
[1, 2].each do |a|
  if a == 1
    puts a
  end
end

# good
[1, 2].each do |a|
  next unless a == 1
  puts a
end

# good
[1, 2].each do |a|
  puts a if a == 1
end

Example: EnforcedStyle: always

# With `always` all conditions at the end of an iteration needs to be
# replaced by next - with `skip_modifier_ifs` the modifier if like
# this one are ignored: `[1, 2].each { |a| puts a if a == 1 }`

# bad
[1, 2].each do |a|
  puts a if a == 1
end

# bad
[1, 2].each do |a|
  if a == 1
    puts a
  end
end

# good
[1, 2].each do |a|
  next unless a == 1
  puts a
end

Use (at % 5).zero? instead of at % 5 == 0.
Open

          progression_tracker.call(at) if at % 5 == 0
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

Checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. This cop can also be configured to do the reverse.

This cop can be customized allowed methods with AllowedMethods. By default, there are no methods to allowed.

This cop disregards #nonzero? as its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

This cop allows comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Integer polymorphic.

Safety:

This cop is unsafe because it cannot be guaranteed that the receiver defines the predicates or can be compared to a number, which may lead to a false positive for non-standard classes.

Example: EnforcedStyle: predicate (default)

# bad
foo == 0
0 > foo
bar.baz > 0

# good
foo.zero?
foo.negative?
bar.baz.positive?

Example: EnforcedStyle: comparison

# bad
foo.zero?
foo.negative?
bar.baz.positive?

# good
foo == 0
0 > foo
bar.baz > 0

Example: AllowedMethods: [] (default) with EnforcedStyle: predicate

# bad
foo == 0
0 > foo
bar.baz > 0

Example: AllowedMethods: [==] with EnforcedStyle: predicate

# good
foo == 0

# bad
0 > foo
bar.baz > 0

Example: AllowedPatterns: [] (default) with EnforcedStyle: comparison

# bad
foo.zero?
foo.negative?
bar.baz.positive?

Example: AllowedPatterns: ['zero'] with EnforcedStyle: predicate

# good
# bad
foo.zero?

# bad
foo.negative?
bar.baz.positive?

Use empty? instead of length == 0.
Open

      return {} if row_styles.length == 0 && cell_styles.length == 0
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

Checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, and receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty?.

NOTE: File, Tempfile, and StringIO do not have empty? so allow size == 0 and size.zero?.

Safety:

This cop is unsafe because it cannot be guaranteed that the receiver has an empty? method that is defined in terms of length. If there is a non-standard class that redefines length or empty?, the cop may register a false positive.

Example:

# bad
[1, 2, 3].length == 0
0 == "foobar".length
array.length < 1
{a: 1, b: 2}.length != 0
string.length > 0
hash.size > 0

# good
[1, 2, 3].empty?
"foobar".empty?
array.empty?
!{a: 1, b: 2}.empty?
!string.empty?
!hash.empty?

end at 305, 4 is not aligned with def at 297, 2.
Open

    end
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

Checks whether the end keywords of method definitions are aligned properly.

Two modes are supported through the EnforcedStyleAlignWith configuration parameter. If it's set to start_of_line (which is the default), the end shall be aligned with the start of the line where the def keyword is. If it's set to def, the end shall be aligned with the def keyword.

Example: EnforcedStyleAlignWith: startofline (default)

# bad

private def foo
            end

# good

private def foo
end

Example: EnforcedStyleAlignWith: def

# bad

private def foo
            end

# good

private def foo
        end

Trailing whitespace detected.
Open

  
Severity: Minor
Found in lib/ntq_excelsior/importer.rb by rubocop

Looks for trailing whitespace in the source code.

Example:

# The line in this example contains spaces after the 0.
# bad
x = 0

# The line in this example ends directly after the 0.
# good
x = 0

Example: AllowInHeredoc: false (default)

# The line in this example contains spaces after the 0.
# bad
code = <<~RUBY
  x = 0
RUBY

# ok
code = <<~RUBY
  x = 0 #{}
RUBY

# good
trailing_whitespace = ' '
code = <<~RUBY
  x = 0#{trailing_whitespace}
RUBY

Example: AllowInHeredoc: true

# The line in this example contains spaces after the 0.
# good
code = <<~RUBY
  x = 0
RUBY
Severity
Category
Status
Source
Language