wrstudios/frodata

View on GitHub

Showing 507 of 507 total issues

Redundant curly braces around a hash parameter.
Open

        super.merge({
          unicode: true,
          default_value: nil
        })
Severity: Minor
Found in lib/frodata/properties/string.rb by rubocop

This cop checks for braces around the last parameter in a method call if the last parameter is a hash. It supports braces, no_braces and context_dependent styles.

Example: EnforcedStyle: braces

# The `braces` style enforces braces around all method
# parameters that are hashes.

# bad
some_method(x, y, a: 1, b: 2)

# good
some_method(x, y, {a: 1, b: 2})

Example: EnforcedStyle: no_braces (default)

# The `no_braces` style checks that the last parameter doesn't
# have braces around it.

# bad
some_method(x, y, {a: 1, b: 2})

# good
some_method(x, y, a: 1, b: 2)

Example: EnforcedStyle: context_dependent

# The `context_dependent` style checks that the last parameter
# doesn't have braces around it, but requires braces if the
# second to last parameter is also a hash literal.

# bad
some_method(x, y, {a: 1, b: 2})
some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)

# good
some_method(x, y, a: 1, b: 2)
some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})

Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used.
Open

      def each_batch(per_page, &block)
Severity: Minor
Found in lib/frodata/query/in_batches.rb by rubocop

This cop checks for unused method arguments.

Example:

# bad

def some_method(used, unused, _unused_but_allowed)
  puts used
end

Example:

# good

def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Unused block argument - val. If it's necessary, use _ or _val as an argument name to indicate that it won't be used.
Open

      metadata = json.select { |key, val| key =~ /@odata/ }
Severity: Minor
Found in lib/frodata/entity.rb by rubocop

This cop checks for unused block arguments.

Example:

# bad

do_something do |used, unused|
  puts used
end

do_something do |bar|
  puts :foo
end

define_method(:foo) do |bar|
  puts :baz
end

Example:

#good

do_something do |used, _unused|
  puts used
end

do_something do
  puts :foo
end

define_method(:foo) do |_bar|
  puts :baz
end

Unused block argument - val. If it's necessary, use _ or _val as an argument name to indicate that it won't be used.
Open

      json.delete_if { |key, val| key =~ /@odata/ }
Severity: Minor
Found in lib/frodata/entity.rb by rubocop

This cop checks for unused block arguments.

Example:

# bad

do_something do |used, unused|
  puts used
end

do_something do |bar|
  puts :foo
end

define_method(:foo) do |bar|
  puts :baz
end

Example:

#good

do_something do |used, _unused|
  puts used
end

do_something do
  puts :foo
end

define_method(:foo) do |_bar|
  puts :baz
end

Use options[:context] = metadata['@odata.context'] instead of options.merge!(context: metadata['@odata.context']).
Open

      options.merge!(context: metadata['@odata.context'])
Severity: Minor
Found in lib/frodata/entity.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)

Use the return of the conditional for variable assignment and comparison.
Open

        if value.is_a?(date_class)
          parsed_value = value
        else
          parsed_value = date_class.parse(value)
        end
Severity: Minor
Found in lib/frodata/properties/date_time.rb by rubocop

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

        "%Y-%m-%dT%H:%M:%SZ"
Severity: Minor
Found in lib/frodata/properties/date_time.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"

Rename is_unicode? to unicode?.
Open

      def is_unicode?
Severity: Minor
Found in lib/frodata/properties/string.rb by rubocop

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value?
end

# good
def value?
end

Space missing after comma.
Open

        unless [0,1,'0','1','true','false',true,false].include?(value)
Severity: Minor
Found in lib/frodata/properties/boolean.rb by rubocop

Checks for comma (,) not followed by some kind of space.

Example:

# bad
[1,2]
{ foo:bar,}

# good
[1, 2]
{ foo:bar, }

Avoid the use of Perl-style backrefs.
Open

            self.srid = $1 ? $2.to_i : DEFAULT_SRID

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)

Final newline missing.
Open

end
Severity: Minor
Found in lib/frodata/properties/integer.rb by rubocop

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

      406 => "Not Acceptable",
Severity: Minor
Found in lib/frodata/errors.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"

Annotation keywords like TODO should be all upper case, followed by a colon, and a space, then a note describing the problem.
Open

      # TODO return action imports exposed by this EntityContainer
Severity: Minor
Found in lib/frodata/entity_container.rb by rubocop

This cop checks that comment annotation keywords are written according to guidelines.

Example:

# bad
# TODO make better

# good
# TODO: make better

# bad
# TODO:make better

# good
# TODO: make better

# bad
# fixme: does not work

# good
# FIXME: does not work

# bad
# Optimize does not work

# good
# OPTIMIZE: does not work

Line is too long. [93/80]
Open

      @services << service if service.is_a?(FrOData::Service) && !@services.include?(service)
Severity: Minor
Found in lib/frodata/service_registry.rb by rubocop

Line is too long. [90/80]
Open

          validation_error "Value '#{value}' is not a date time format that can be parsed"
Severity: Minor
Found in lib/frodata/properties/date_time.rb by rubocop

Line is too long. [130/80]
Open

          validation_error "Value is outside accepted range: #{min_value} to #{max_value}, or has more than 29 significant digits"
Severity: Minor
Found in lib/frodata/properties/decimal.rb by rubocop

Space missing after comma.
Open

        unless [0,1,'0','1','true','false',true,false].include?(value)
Severity: Minor
Found in lib/frodata/properties/boolean.rb by rubocop

Checks for comma (,) not followed by some kind of space.

Example:

# bad
[1,2]
{ foo:bar,}

# good
[1, 2]
{ foo:bar, }

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

        if value > max_value || value < min_value
Severity: Minor
Found in lib/frodata/properties/number.rb by rubocop

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

          if srs_attr

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

Useless private access modifier.
Open

        private

This cop checks for redundant access modifiers, including those with no code, those which are repeated, and leading public modifiers in a class or module body. Conditionally-defined methods are considered as always being defined, and thus access modifiers guarding such methods are not redundant.

Example:

class Foo
  public # this is redundant (default access is public)

  def method
  end

  private # this is not redundant (a method is defined)
  def method2
  end

  private # this is redundant (no following methods are defined)
end

Example:

class Foo
  # The following is not redundant (conditionally defined methods are
  # considered as always defining a method)
  private

  if condition?
    def method
    end
  end

  protected # this is not redundant (method is defined)

  define_method(:method2) do
  end

  protected # this is redundant (repeated from previous modifier)

  [1,2,3].each do |i|
    define_method("foo#{i}") do
    end
  end

  # The following is redundant (methods defined on the class'
  # singleton class are not affected by the public modifier)
  public

  def self.method3
  end
end

Example:

# Lint/UselessAccessModifier:
#   ContextCreatingMethods:
#     - concerning
require 'active_support/concern'
class Foo
  concerning :Bar do
    def some_public_method
    end

    private

    def some_private_method
    end
  end

  # this is not redundant because `concerning` created its own context
  private

  def some_other_private_method
  end
end

Example:

# Lint/UselessAccessModifier:
#   MethodCreatingMethods:
#     - delegate
require 'active_support/core_ext/module/delegation'
class Foo
  # this is not redundant because `delegate` creates methods
  private

  delegate :method_a, to: :method_b
end
Severity
Category
Status
Source
Language