am-kantox/see_as_vee

View on GitHub

Showing 21 of 21 total issues

Method file_with_type has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def file_with_type whatever
      file =  case whatever
              when IO then whatever
              when String
                File.exist?(whatever) ? File.new(whatever) : Privates.tempfile(whatever)
Severity: Minor
Found in lib/see_as_vee/helpers.rb - About 55 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

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

      def degroup hashes, columns, delimiter
        return hashes if (columns = [*columns]).empty?

        hashes.tap do |hs|
          hs.each do |hash|
Severity: Minor
Found in lib/see_as_vee/producers/hashes.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

Unnecessary utf-8 encoding comment.
Open

# coding: utf-8
Severity: Minor
Found in see_as_vee.gemspec by rubocop

Avoid multi-line chains of blocks.
Open

      end.compact.map.with_index do |row, idx|
Severity: Minor
Found in lib/see_as_vee/sheet.rb by rubocop

This cop checks for chaining of a block after another block that spans multiple lines.

Example:

Thread.list.find_all do |t|
  t.alive?
end.map do |t|
  t.object_id
end

Use warn instead of $stderr.puts to allow such output to be disabled.
Open

  $stderr.puts 'Run `bundle install` to install missing gems'
Severity: Minor
Found in Rakefile by rubocop

This cop identifies places where $stderr.puts can be replaced by warn. The latter has the advantage of easily being disabled by, e.g. the -W0 interpreter flag, or setting $VERBOSE to nil.

Example:

# bad
$stderr.puts('hello')

# good
warn('hello')

Favor a normal if-statement over a modifier clause in a multiline statement.
Open

        content =
          "\xFF\xFE".force_encoding(Encoding::UTF_16LE) <<
          content.encode(Encoding::UTF_16LE) if for_ms_excel
Severity: Minor
Found in lib/see_as_vee/sheet.rb by rubocop

Checks for uses of if/unless modifiers with multiple-lines bodies.

Example:

# bad
{
  result: 'this should not happen'
} unless cond

# good
{ result: 'ok' } if cond

Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency axlsx should appear before simple_xlsx_reader.
Open

  spec.add_dependency 'axlsx'
Severity: Minor
Found in see_as_vee.gemspec by rubocop

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'

Use warn instead of $stderr.puts to allow such output to be disabled.
Open

  $stderr.puts e.message
Severity: Minor
Found in Rakefile by rubocop

This cop identifies places where $stderr.puts can be replaced by warn. The latter has the advantage of easily being disabled by, e.g. the -W0 interpreter flag, or setting $VERBOSE to nil.

Example:

# bad
$stderr.puts('hello')

# good
warn('hello')

Place the . on the next line, together with the method name.
Open

        gsub(/\A[[:space:]]+/, '').
Severity: Minor
Found in lib/see_as_vee/sheet.rb by rubocop

This cop checks the . position in multi-line method calls.

Example: EnforcedStyle: leading (default)

# bad
something.
  mehod

# good
something
  .method

Example: EnforcedStyle: trailing

# bad
something
  .method

# good
something.
  mehod

Unnecessary utf-8 encoding comment.
Open

# encoding: UTF-8
Severity: Minor
Found in Rakefile by rubocop

Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency pry should appear before rspec.
Open

  spec.add_development_dependency 'pry'
Severity: Minor
Found in see_as_vee.gemspec by rubocop

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'

Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency awesome_print should appear before pry.
Open

  spec.add_development_dependency 'awesome_print'
Severity: Minor
Found in see_as_vee.gemspec by rubocop

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'

Add an empty line after magic comments.
Open

lib = File.expand_path('../lib', __FILE__)
Severity: Minor
Found in see_as_vee.gemspec by rubocop

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

Place the . on the next line, together with the method name.
Open

        gsub(/[[:space:]]+\z/, '').
Severity: Minor
Found in lib/see_as_vee/sheet.rb by rubocop

This cop checks the . position in multi-line method calls.

Example: EnforcedStyle: leading (default)

# bad
something.
  mehod

# good
something
  .method

Example: EnforcedStyle: trailing

# bad
something
  .method

# good
something.
  mehod

Shadowing outer local variable - f.
Open

        File.open(f.path, mode) { |f| f.write content }
Severity: Minor
Found in lib/see_as_vee/sheet.rb by rubocop

This cop looks for use of the same name as outer local variables for block arguments or block local variables. This is a mimic of the warning "shadowing outer local variable - foo" from ruby -cw.

Example:

# bad

def some_method
  foo = 1

  2.times do |foo| # shadowing outer `foo`
    do_something(foo)
  end
end

Example:

# good

def some_method
  foo = 1

  2.times do |bar|
    do_something(bar)
  end
end

%w-literals should be delimited by [ and ].
Open

        ext.to_sym if %w(xlsx csv).include?(ext)
Severity: Minor
Found in lib/see_as_vee/helpers.rb 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 params[:col_sep] = "\t" instead of params.merge!(col_sep: "\t").
Open

      params.merge!(col_sep: "\t") if for_ms_excel
Severity: Minor
Found in lib/see_as_vee/sheet.rb by rubocop

This cop identifies places where Hash#merge! can be replaced by Hash#[]=.

Example:

hash.merge!(a: 1)
hash.merge!({'key' => 'value'})
hash.merge!(a: 1, b: 2)

Do not place comments on the same line as the def keyword.
Open

      def normalize! symbol = true # to_s otherwise
Severity: Minor
Found in lib/see_as_vee/producers/hashes.rb by rubocop

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

Add an empty line after magic comments.
Open

require 'rubygems'
Severity: Minor
Found in Rakefile by rubocop

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

Place the . on the next line, together with the method name.
Open

      str.
Severity: Minor
Found in lib/see_as_vee/sheet.rb by rubocop

This cop checks the . position in multi-line method calls.

Example: EnforcedStyle: leading (default)

# bad
something.
  mehod

# good
something
  .method

Example: EnforcedStyle: trailing

# bad
something
  .method

# good
something.
  mehod
Severity
Category
Status
Source
Language