datacite/levriero

View on GitHub

Showing 368 of 369 total issues

Unused method argument - sqs_msg.
Open

  def self.grab_record(sqs_msg: nil, data: nil)
Severity: Minor
Found in app/models/usage_update.rb by rubocop

Checks for unused method arguments.

Example:

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

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

Example: AllowUnusedKeywordArguments: false (default)

# bad
def do_something(used, unused: 42)
  used
end

Example: AllowUnusedKeywordArguments: true

# good
def do_something(used, unused: 42)
  used
end

Example: IgnoreEmptyMethods: true (default)

# good
def do_something(unused)
end

Example: IgnoreEmptyMethods: false

# bad
def do_something(unused)
end

Example: IgnoreNotImplementedMethods: true (default)

# good
def do_something(unused)
  raise NotImplementedError
end

def do_something_else(unused)
  fail "TODO"
end

Example: IgnoreNotImplementedMethods: false

# bad
def do_something(unused)
  raise NotImplementedError
end

def do_something_else(unused)
  fail "TODO"
end

Do not read from ENV directly post initialization.
Open

      source_token = ENV["DATACITE_URL_SOURCE_TOKEN"]
Severity: Minor
Found in app/models/related_url.rb by rubocop

Method User#orcid is defined at both app/models/user.rb:5 and app/models/user.rb:24.
Open

  alias_method :orcid, :uid
Severity: Minor
Found in app/models/user.rb by rubocop

Checks for duplicated instance (or singleton) method definitions.

Example:

# bad

def foo
  1
end

def foo
  2
end

Example:

# bad

def foo
  1
end

alias foo bar

Example:

# good

def foo
  1
end

def bar
  2
end

Example:

# good

def foo
  1
end

alias bar foo

include is used at the top level. Use inside class or module.
Open

include FileUtils
Severity: Minor
Found in bin/setup by rubocop

Checks that include, extend and prepend statements appear inside classes and modules, not at the top level, so as to not affect the behavior of Object.

Example:

# bad
include M

class C
end

# bad
extend M

class C
end

# bad
prepend M

class C
end

# good
class C
  include M
end

# good
class C
  extend M
end

# good
class C
  prepend M
end

Do not read from ENV directly post initialization.
Open

    Aws::SQS::Client.new(region: ENV["AWS_REGION"])
Severity: Minor
Found in app/models/usage_update.rb by rubocop

Do not read from ENV directly post initialization.
Open

      if ENV["EVENTDATA_TOKEN"].present?
Severity: Minor
Found in app/models/related_identifier.rb by rubocop

Do not read from ENV directly post initialization.
Open

                                          bearer: ENV["STAFF_ADMIN_TOKEN"],
Severity: Minor
Found in app/models/related_pmid.rb by rubocop

Call super to initialize state of the parent class.
Open

  def initialize(report, _options = {})
    @errors = report.body.fetch("errors") if report.body.fetch("errors",
                                                               nil).present?
    return @errors if report.body.fetch("errors", nil).present?
    return [{ "errors" => { "title" => "The report is blank" } }] if report.body.blank?
Severity: Minor
Found in app/models/report.rb by rubocop

Checks for the presence of constructors and lifecycle callbacks without calls to super.

This cop does not consider method_missing (and respond_to_missing?) because in some cases it makes sense to overtake what is considered a missing method. In other cases, the theoretical ideal handling could be challenging or verbose for no actual gain.

Example:

# bad
class Employee < Person
  def initialize(name, salary)
    @salary = salary
  end
end

# good
class Employee < Person
  def initialize(name, salary)
    super(name)
    @salary = salary
  end
end

# bad
Employee = Class.new(Person) do
  def initialize(name, salary)
    @salary = salary
  end
end

# good
Employee = Class.new(Person) do
  def initialize(name, salary)
    super(name)
    @salary = salary
  end
end

# bad
class Parent
  def self.inherited(base)
    do_something
  end
end

# good
class Parent
  def self.inherited(base)
    super
    do_something
  end
end

Do not read from ENV directly post initialization.
Open

    push_url = "#{ENV['LAGOTTINO_URL']}/events"
Severity: Minor
Found in app/models/usage_update.rb by rubocop

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

gem 'next_rails'
Severity: Minor
Found in Gemfile 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"

include is used at the top level. Use inside class or module.
Open

include FileUtils
Severity: Minor
Found in bin/update by rubocop

Checks that include, extend and prepend statements appear inside classes and modules, not at the top level, so as to not affect the behavior of Object.

Example:

# bad
include M

class C
end

# bad
extend M

class C
end

# bad
prepend M

class C
end

# good
class C
  include M
end

# good
class C
  extend M
end

# good
class C
  prepend M
end

Do not read from ENV directly post initialization.
Open

        source_token = ENV["DATACITE_OTHER_SOURCE_TOKEN"]
Severity: Minor
Found in app/models/related_identifier.rb by rubocop

Do not read from ENV directly post initialization.
Open

        push_url = "#{ENV['LAGOTTINO_URL']}/events"
Severity: Minor
Found in app/models/related_igsn.rb by rubocop

Rename is_admin_or_staff? to admin_or_staff?.
Open

  def is_admin_or_staff?
Severity: Minor
Found in app/models/user.rb by rubocop

Checks that predicate methods names end with a question mark and do not start with a forbidden prefix.

A method is determined to be a predicate method if its name starts with one of the prefixes defined in the NamePrefix configuration. You can change what prefixes are considered by changing this option. Any method name that starts with one of these prefixes is required by the cop to end with a ?. Other methods can be allowed by adding to the AllowedMethods configuration.

NOTE: The is_a? method is allowed by default.

If ForbiddenPrefixes is set, methods that start with the configured prefixes will not be allowed and will be removed by autocorrection.

In other words, if ForbiddenPrefixes is empty, a method named is_foo will register an offense only due to the lack of question mark (and will be autocorrected to is_foo?). If ForbiddenPrefixes contains is_, is_foo will register an offense both because the ? is missing and because of the is_ prefix, and will be corrected to foo?.

NOTE: ForbiddenPrefixes is only applied to prefixes in NamePrefix; a prefix in the former but not the latter will not be considered by this cop.

Example:

# bad
def is_even(value)
end

def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value
end

def has_value?
end

# good
def value?
end

Example: AllowedMethods: ['is_a?'] (default)

# good
def is_a?(value)
end

Do not read from ENV directly post initialization.
Open

        source_token = ENV["DATACITE_CROSSREF_SOURCE_TOKEN"]
Severity: Minor
Found in app/models/related_identifier.rb by rubocop

Avoid immutable Array literals in loops. It is better to extract it into a local variable or a constant.
Open

        if [200, 201].include?(response.status)
Severity: Minor
Found in app/models/related_identifier.rb by rubocop

Avoid immutable Array literals in loops. It is better to extract it into a local variable or a constant.
Open

        if [200, 201].include?(response.status)
Severity: Minor
Found in app/models/related_url.rb by rubocop

Do not read from ENV directly post initialization.
Open

        source_token = ENV["DATACITE_RELATED_SOURCE_TOKEN"]
Severity: Minor
Found in app/models/related_identifier.rb by rubocop

Do not read from ENV directly post initialization.
Open

        push_url = "#{ENV['LAGOTTINO_URL']}/events"
Severity: Minor
Found in app/models/related_identifier.rb by rubocop

Do not read from ENV directly post initialization.
Open

                                          bearer: ENV["STAFF_ADMIN_TOKEN"],
Severity: Minor
Found in app/models/related_url.rb by rubocop
Severity
Category
Status
Source
Language