MatteoRagni/cas-rb

View on GitHub
Mr.CAS.gemspec

Summary

Maintainability
Test Coverage

Use String#end_with? instead of a regex match anchored to the end of the string.
Open

  s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop identifies unnecessary use of a regex where String#end_with? would suffice.

Example:

# bad
'abc' =~ /bc\Z/
'abc'.match(/bc\Z/)

# good
'abc'.end_with?('bc')

Use snake_case for variable names.
Open

version_MAYOR = "0"
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

Example: EnforcedStyle: snake_case (default)

# bad
fooBar = 1

# good
foo_bar = 1

Example: EnforcedStyle: camelCase

# bad
foo_bar = 1

# good
fooBar = 1

required_ruby_version (2.0, declared in Mr.CAS.gemspec) and TargetRubyVersion (2.1, declared in .rubocop.yml) should be equal.
Open

  s.required_ruby_version = '>= 2.0'
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

Checks that required_ruby_version of gemspec and TargetRubyVersion of .rubocop.yml are equal. Thereby, RuboCop to perform static analysis working on the version required by gemspec.

Example:

# When `TargetRubyVersion` of .rubocop.yml is `2.3`.

# bad
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.2.0'
end

# bad
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.4.0'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.3.0'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.3'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = ['>= 2.3.0', '< 2.5.0']
end

Avoid the use of Perl-style backrefs.
Open

  version_PATCH = $3
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Pass &:chomp as an argument to map! instead of a block.
Open

changelog = (IO.readlines(changelog).map! { |l| l.chomp } - [""])[-1]
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

Use symbols as procs when possible.

Example:

# bad
something.map { |s| s.upcase }

# good
something.map(&:upcase)

Script file Mr.CAS.gemspec doesn't have execute permission.
Open

#!/usr/bin/env ruby
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

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

File.open(File.expand_path('lib/version.rb', File.dirname(__FILE__)), "w") { |f| f.puts version_rb }
Severity: Minor
Found in Mr.CAS.gemspec 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"

Freeze mutable objects assigned to constants.
Open

VERSION = "#{version_MAYOR}.#{version_MINOR}.#{version_PATCH}"
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

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

  s.files = Dir["lib/**/**"]
Severity: Minor
Found in Mr.CAS.gemspec 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 snake_case for variable names.
Open

version_PATCH = "0"
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

Example: EnforcedStyle: snake_case (default)

# bad
fooBar = 1

# good
foo_bar = 1

Example: EnforcedStyle: camelCase

# bad
foo_bar = 1

# good
fooBar = 1

Favor format over String#%.
Open

  s.date = "#{'%04d' % DATE.year}-#{'%02d' % DATE.month}-#{'%02d' % DATE.day}"
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop enforces the use of a single string formatting utility. Valid options include Kernel#format, Kernel#sprintf and String#%.

The detection of String#% cannot be implemented in a reliable manner for all cases, so only two scenarios are considered - if the first argument is a string literal and if the second argument is an array literal.

Example: EnforcedStyle: format(default)

# bad
puts sprintf('%10s', 'hoge')
puts '%10s' % 'hoge'

# good
puts format('%10s', 'hoge')

Example: EnforcedStyle: sprintf

# bad
puts format('%10s', 'hoge')
puts '%10s' % 'hoge'

# good
puts sprintf('%10s', 'hoge')

Example: EnforcedStyle: percent

# bad
puts format('%10s', 'hoge')
puts sprintf('%10s', 'hoge')

# good
puts '%10s' % 'hoge'

Use meaningful heredoc delimiters.
Open

EOV
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop checks that your heredocs are using meaningful delimiters. By default it disallows END and EO*, and can be configured through blacklisting additional delimiters.

Example:

# good
<<-SQL
  SELECT * FROM foo
SQL

# bad
<<-END
  SELECT * FROM foo
END

# bad
<<-EOS
  SELECT * FROM foo
EOS

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

changelog = (IO.readlines(changelog).map! { |l| l.chomp } - [""])[-1]
Severity: Minor
Found in Mr.CAS.gemspec 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"

Line is too long. [113/80]
Open

  s.summary = 'A [M]inimalistic [R]uby [C]omputer [A]lgebra [S]ystem, for rapid prototyping and meta-programming'
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

Prefer $PROGRAM_NAME over $0.
Open

  s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

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

version_MAYOR = "0"
Severity: Minor
Found in Mr.CAS.gemspec 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 snake_case for variable names.
Open

  version_MINOR = $2
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

Example: EnforcedStyle: snake_case (default)

# bad
fooBar = 1

# good
foo_bar = 1

Example: EnforcedStyle: camelCase

# bad
foo_bar = 1

# good
fooBar = 1

Favor format over String#%.
Open

  s.date = "#{'%04d' % DATE.year}-#{'%02d' % DATE.month}-#{'%02d' % DATE.day}"
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop enforces the use of a single string formatting utility. Valid options include Kernel#format, Kernel#sprintf and String#%.

The detection of String#% cannot be implemented in a reliable manner for all cases, so only two scenarios are considered - if the first argument is a string literal and if the second argument is an array literal.

Example: EnforcedStyle: format(default)

# bad
puts sprintf('%10s', 'hoge')
puts '%10s' % 'hoge'

# good
puts format('%10s', 'hoge')

Example: EnforcedStyle: sprintf

# bad
puts format('%10s', 'hoge')
puts '%10s' % 'hoge'

# good
puts sprintf('%10s', 'hoge')

Example: EnforcedStyle: percent

# bad
puts format('%10s', 'hoge')
puts sprintf('%10s', 'hoge')

# good
puts '%10s' % 'hoge'

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

version_MINOR = "0"
Severity: Minor
Found in Mr.CAS.gemspec 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 spaces for indentation in a heredoc by using some library(e.g. ActiveSupport's String#strip_heredoc).
Open

#!/usr/bin/env ruby

# Copyright (c) 2016 Matteo Ragni
#
# Permission is hereby granted, free of charge, to any person
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cops checks the indentation of the here document bodies. The bodies are indented one step. In Ruby 2.3 or newer, squiggly heredocs (<<~) should be used. If you use the older rubies, you should introduce some library to your project (e.g. ActiveSupport, Powerpack or Unindent). Note: When Metrics/LineLength's AllowHeredoc is false(not default), this cop does not add any offenses for long here documents to avoid Metrics/LineLength's offenses.

Example:

# bad
<<-RUBY
something
RUBY

# good
# When EnforcedStyle is squiggly, bad code is auto-corrected to the
# following code.
<<~RUBY
  something
RUBY

# good
# When EnforcedStyle is active_support, bad code is auto-corrected to
# the following code.
<<-RUBY.strip_heredoc
  something
RUBY

Line is too long. [100/80]
Open

File.open(File.expand_path('lib/version.rb', File.dirname(__FILE__)), "w") { |f| f.puts version_rb }
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

Use snake_case for variable names.
Open

version_MINOR = "0"
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

Example: EnforcedStyle: snake_case (default)

# bad
fooBar = 1

# good
foo_bar = 1

Example: EnforcedStyle: camelCase

# bad
foo_bar = 1

# good
fooBar = 1

Favor format over String#%.
Open

  s.date = "#{'%04d' % DATE.year}-#{'%02d' % DATE.month}-#{'%02d' % DATE.day}"
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop enforces the use of a single string formatting utility. Valid options include Kernel#format, Kernel#sprintf and String#%.

The detection of String#% cannot be implemented in a reliable manner for all cases, so only two scenarios are considered - if the first argument is a string literal and if the second argument is an array literal.

Example: EnforcedStyle: format(default)

# bad
puts sprintf('%10s', 'hoge')
puts '%10s' % 'hoge'

# good
puts format('%10s', 'hoge')

Example: EnforcedStyle: sprintf

# bad
puts format('%10s', 'hoge')
puts '%10s' % 'hoge'

# good
puts sprintf('%10s', 'hoge')

Example: EnforcedStyle: percent

# bad
puts format('%10s', 'hoge')
puts sprintf('%10s', 'hoge')

# good
puts '%10s' % 'hoge'

Line is too long. [81/80]
Open

  s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

Use snake_case for variable names.
Open

  version_PATCH = $3
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

Example: EnforcedStyle: snake_case (default)

# bad
fooBar = 1

# good
foo_bar = 1

Example: EnforcedStyle: camelCase

# bad
foo_bar = 1

# good
fooBar = 1

Avoid the use of Perl-style backrefs.
Open

  version_MAYOR = $1
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

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

  s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
Severity: Minor
Found in Mr.CAS.gemspec 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 the use of Perl-style backrefs.
Open

  version_MINOR = $2
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

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

version_PATCH = "0"
Severity: Minor
Found in Mr.CAS.gemspec 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 snake_case for variable names.
Open

  version_MAYOR = $1
Severity: Minor
Found in Mr.CAS.gemspec by rubocop

This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

Example: EnforcedStyle: snake_case (default)

# bad
fooBar = 1

# good
foo_bar = 1

Example: EnforcedStyle: camelCase

# bad
foo_bar = 1

# good
fooBar = 1

There are no issues that match your filters.

Category
Status