9troisquarts/ntq-excelsior

View on GitHub

Showing 211 of 211 total issues

Redundant return detected.
Open

      return { status: :error, errors: @errors.join(", ") }
Severity: Minor
Found in lib/ntq_excelsior/importer.rb by rubocop

Checks for redundant return expressions.

Example:

# These bad cases should be extended to handle methods whose body is
# if/else or a case expression with a default branch.

# bad
def test
  return something
end

# bad
def test
  one
  two
  three
  return something
end

# bad
def test
  return something if something_else
end

# good
def test
  something if something_else
end

# good
def test
  if x
  elsif y
  else
  end
end

Example: AllowMultipleReturnValues: false (default)

# bad
def test
  return x, y
end

Example: AllowMultipleReturnValues: true

# good
def test
  return x, y
end

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

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

Use 2 (not 4) spaces for indentation.
Open

      package = Axlsx::Package.new
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

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: AllowedPatterns: ['^\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

Final newline missing.
Open

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

Looks for trailing blank lines and a final newline in the source code.

Example: EnforcedStyle: final_newline (default)

# `final_newline` looks for one newline at the end of files.

# bad
class Foo; end

# EOF

# bad
class Foo; end # EOF

# good
class Foo; end
# EOF

Example: EnforcedStyle: finalblankline

# `final_blank_line` looks for one blank line followed by a new line
# at the end of files.

# bad
class Foo; end
# EOF

# bad
class Foo; end # EOF

# good
class Foo; end

# EOF

Use each instead of each_with_index.
Open

      (schema[:extra_headers] || []).each_with_index do |header|
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

Checks for redundant with_index.

Example:

# bad
ary.each_with_index do |v|
  v
end

# good
ary.each do |v|
  v
end

# bad
ary.each.with_index do |v|
  v
end

# good
ary.each do |v|
  v
end

Group together all attr_accessor attributes.
Open

    attr_accessor :progression_tracker
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

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

        format_code: 'dd-mm-yyyy hh:mm:ss'
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"

Prefer double-quoted strings inside interpolations.
Open

      "#{lock.include?(:col) ? '$' : ''}#{column_name(col)}#{lock.include?(:row) ? '$' : ''}#{row}"
Severity: Minor
Found in lib/ntq_excelsior/exporter.rb by rubocop

Checks that quotes inside string, symbol, and regexp interpolations match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
string = "Tests #{success ? "PASS" : "FAIL"}"
symbol = :"Tests #{success ? "PASS" : "FAIL"}"
heredoc = <<~TEXT
  Tests #{success ? "PASS" : "FAIL"}
TEXT
regexp = /Tests #{success ? "PASS" : "FAIL"}/

# good
string = "Tests #{success ? 'PASS' : 'FAIL'}"
symbol = :"Tests #{success ? 'PASS' : 'FAIL'}"
heredoc = <<~TEXT
  Tests #{success ? 'PASS' : 'FAIL'}
TEXT
regexp = /Tests #{success ? 'PASS' : 'FAIL'}/

Example: EnforcedStyle: double_quotes

# bad
string = "Tests #{success ? 'PASS' : 'FAIL'}"
symbol = :"Tests #{success ? 'PASS' : 'FAIL'}"
heredoc = <<~TEXT
  Tests #{success ? 'PASS' : 'FAIL'}
TEXT
regexp = /Tests #{success ? 'PASS' : 'FAIL'}/

# good
string = "Tests #{success ? "PASS" : "FAIL"}"
symbol = :"Tests #{success ? "PASS" : "FAIL"}"
heredoc = <<~TEXT
  Tests #{success ? "PASS" : "FAIL"}
TEXT
regexp = /Tests #{success ? "PASS" : "FAIL"}/

Use !empty? instead of size > 0.
Open

      return count unless columns_with_children && columns_with_children.size > 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?

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?

Group together all attr_accessor attributes.
Open

    attr_accessor :context
Severity: Minor
Found in lib/ntq_excelsior/importer.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 gsub_enclosure && header.scan(/^\/[\^]?([^(\$\/)]+)[\$]?\/[i]?$/i) && $1
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

Prefer ::Regexp.last_match(1) over $1.
Open

      if gsub_enclosure && header.scan(/^\/[\^]?([^(\$\/)]+)[\$]?\/[i]?$/i) && $1
Severity: Minor
Found in lib/ntq_excelsior/importer.rb by rubocop

Looks for uses of Perl-style regexp match backreferences and their English versions like $1, $2, $&, &+, $MATCH, $PREMATCH, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Final newline missing.
Open

end
Severity: Minor
Found in ntq_excelsior.gemspec by rubocop

Looks for trailing blank lines and a final newline in the source code.

Example: EnforcedStyle: final_newline (default)

# `final_newline` looks for one newline at the end of files.

# bad
class Foo; end

# EOF

# bad
class Foo; end # EOF

# good
class Foo; end
# EOF

Example: EnforcedStyle: finalblankline

# `final_blank_line` looks for one blank line followed by a new line
# at the end of files.

# bad
class Foo; end
# EOF

# bad
class Foo; end # EOF

# good
class Foo; end

# EOF

Redundant begin block detected.
Open

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

Checks for redundant begin blocks.

Currently it checks for code like this:

Example:

# bad
def redundant
  begin
    ala
    bala
  rescue StandardError => e
    something
  end
end

# good
def preferred
  ala
  bala
rescue StandardError => e
  something
end

# bad
begin
  do_something
end

# good
do_something

# bad
# When using Ruby 2.5 or later.
do_something do
  begin
    something
  rescue => ex
    anything
  end
end

# good
# In Ruby 2.5 or later, you can omit `begin` in `do-end` block.
do_something do
  something
rescue => ex
  anything
end

# good
# Stabby lambdas don't support implicit `begin` in `do-end` blocks.
-> do
  begin
    foo
  rescue Bar
    baz
  end
end

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

  class Context < OpenStruct
Severity: Minor
Found in lib/ntq_excelsior/context.rb by rubocop

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

Don't use parentheses around a logical expression.
Open

      if (self.class.autosave.nil? || self.class.autosave)
Severity: Minor
Found in lib/ntq_excelsior/importer.rb by rubocop

Checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

end at 307, 1 is not aligned with class at 4, 2.
Open

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

Checks whether the end keywords are aligned properly.

Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

This Layout/EndAlignment cop aligns with keywords (e.g. if, while, case) by default. On the other hand, Layout/BeginEndAlignment cop aligns with EnforcedStyleAlignWith: start_of_line by default due to ||= begin tends to align with the start of the line. Layout/DefEndAlignment cop also aligns with EnforcedStyleAlignWith: start_of_line by default. These style can be configured by each cop.

Example: EnforcedStyleAlignWith: keyword (default)

# bad

variable = if true
    end

# good

variable = if true
           end

variable =
  if true
  end

Example: EnforcedStyleAlignWith: variable

# bad

variable = if true
    end

# good

variable = if true
end

variable =
  if true
  end

Example: EnforcedStyleAlignWith: startofline

# bad

variable = if true
    end

puts(if true
     end)

# good

variable = if true
end

puts(if true
end)

variable =
  if true
  end

Use %r around regular expression.
Open

      if gsub_enclosure && header.scan(/^\/[\^]?([^(\$\/)]+)[\$]?\/[i]?$/i) && $1
Severity: Minor
Found in lib/ntq_excelsior/importer.rb by rubocop

Enforces using // or %r around regular expressions.

NOTE: The following %r cases using a regexp starts with a blank or = as a method argument allowed to prevent syntax errors.

do_something %r{ regexp} # `do_something / regexp/` is an invalid syntax.
do_something %r{=regexp} # `do_something /=regexp/` is an invalid syntax.

Example: EnforcedStyle: slashes (default)

# bad
snake_case = %r{^[\dA-Z_]+$}

# bad
regex = %r{
  foo
  (bar)
  (baz)
}x

# good
snake_case = /^[\dA-Z_]+$/

# good
regex = /
  foo
  (bar)
  (baz)
/x

Example: EnforcedStyle: percent_r

# bad
snake_case = /^[\dA-Z_]+$/

# bad
regex = /
  foo
  (bar)
  (baz)
/x

# good
snake_case = %r{^[\dA-Z_]+$}

# good
regex = %r{
  foo
  (bar)
  (baz)
}x

Example: EnforcedStyle: mixed

# bad
snake_case = %r{^[\dA-Z_]+$}

# bad
regex = /
  foo
  (bar)
  (baz)
/x

# good
snake_case = /^[\dA-Z_]+$/

# good
regex = %r{
  foo
  (bar)
  (baz)
}x

Example: AllowInnerSlashes: false (default)

# If `false`, the cop will always recommend using `%r` if one or more
# slashes are found in the regexp string.

# bad
x =~ /home\//

# good
x =~ %r{home/}

Example: AllowInnerSlashes: true

# good
x =~ /home\//

Inconsistent indentation detected.
Open

        def export
      package = Axlsx::Package.new
      wb = package.workbook
      wb_styles = wb.styles

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

Checks for inconsistent indentation.

The difference between indented_internal_methods and normal is that the indented_internal_methods style prescribes that in classes and modules the protected and private modifier keywords shall be indented the same as public methods and that protected and private members shall be indented one step more than the modifiers. Other than that, both styles mean that entities on the same logical depth shall have the same indentation.

Example: EnforcedStyle: normal (default)

# bad
class A
  def test
    puts 'hello'
     puts 'world'
  end
end

# bad
class A
  def test
    puts 'hello'
    puts 'world'
  end

  protected

    def foo
    end

  private

    def bar
    end
end

# good
class A
  def test
    puts 'hello'
    puts 'world'
  end
end

# good
class A
  def test
    puts 'hello'
    puts 'world'
  end

  protected

  def foo
  end

  private

  def bar
  end
end

Example: EnforcedStyle: indentedinternalmethods

# bad
class A
  def test
    puts 'hello'
     puts 'world'
  end
end

# bad
class A
  def test
    puts 'hello'
    puts 'world'
  end

  protected

  def foo
  end

  private

  def bar
  end
end

# good
class A
  def test
    puts 'hello'
    puts 'world'
  end
end

# good
class A
  def test
    puts 'hello'
    puts 'world'
  end

  protected

    def foo
    end

  private

    def bar
    end
end
Severity
Category
Status
Source
Language