hpi-swt2/workshop-portal

View on GitHub

Showing 494 of 494 total issues

Line is too long. [114/80]
Open

      errors.add(:event, "Die Bewerbungen wurden bereits bearbeitet, eine Statusänderung ist nicht mehr erlaubt.")
Severity: Minor
Found in app/models/application_letter.rb by rubocop

Redundant self detected.
Open

    self.birth_date >= 18.years.ago
Severity: Minor
Found in app/models/profile.rb by rubocop

This cop checks for redundant uses of self.

The usage of self is only needed when:

  • Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.

  • Calling an attribute writer to prevent an local variable assignment.

Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.

Note we allow uses of self with operators because it would be awkward otherwise.

Example:

# bad
def foo(bar)
  self.baz
end

# good
def foo(bar)
  self.bar  # Resolves name clash with the argument.
end

def foo
  bar = 1
  self.bar  # Resolves name clash with the local variable.
end

def foo
  %w[x y z].select do |bar|
    self.bar == bar  # Resolves name clash with argument of the block.
  end
end

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

    first_name + " " +  last_name
Severity: Minor
Found in app/models/profile.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 single-quoted strings when you don't need string interpolation or special symbols.
Open

    street_name + ", " + zip_code + " " +  city + ", " + state + ", " + country
Severity: Minor
Found in app/models/profile.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 %w or %W for an array of words.
Open

  POSSIBLE_GENDERS = ['male', 'female', 'other']
Severity: Minor
Found in app/models/profile.rb by rubocop

This cop can check for array literals made up of word-like strings, that are not using the %w() syntax.

Alternatively, it can check for uses of the %w() syntax, in projects which do not want to include that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of 3 will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%w[foo bar baz]

# bad
['foo', 'bar', 'baz']

Example: EnforcedStyle: brackets

# good
['foo', 'bar', 'baz']

# bad
%w[foo bar baz]

Put empty method definitions on a single line.
Open

  def show
  end

This cop checks for the formatting of empty method definitions. By default it enforces empty method definitions to go on a single line (compact style), but it can be configured to enforce the end to go on its own line (expanded style).

Note: A method definition is not considered empty if it contains comments.

Example: EnforcedStyle: compact (default)

# bad
def foo(bar)
end

def self.foo(bar)
end

# good
def foo(bar); end

def foo(bar)
  # baz
end

def self.foo(bar); end

Example: EnforcedStyle: expanded

# bad
def foo(bar); end

def self.foo(bar); end

# good
def foo(bar)
end

def self.foo(bar)
end

Space missing to the left of {.
Open

      filters = (params[:filter] || {}).select { |k, v| v == '1' }.map{ |k, v| k.to_s }

Checks that block braces have or don't have a space before the opening brace depending on configuration.

Example:

# bad
foo.map{ |a|
  a.bar.to_s
}

# good
foo.map { |a|
  a.bar.to_s
}

Element (label.required:after) is overqualified, just use .required without element name.
Open

label.required:after {

Rule doesn't have all its properties in alphabetical order.
Open

#error_explanation {
Severity: Minor
Found in app/assets/stylesheets/scaffold.css by csslint

Don't use IDs in selectors.
Open

#error_explanation ul li {
Severity: Minor
Found in app/assets/stylesheets/scaffold.css by csslint

Trailing whitespace detected.
Open

  
Severity: Minor
Found in app/models/request.rb by rubocop

Line is too long. [98/80]
Open

  # 2. All participants that have to submit an letter of agreement and did do so, ordered by name.
Severity: Minor
Found in app/models/event.rb by rubocop

Line is too long. [84/80]
Open

  validates :max_participants, numericality: { only_integer: true, greater_than: 0 }
Severity: Minor
Found in app/models/event.rb by rubocop

Line is too long. [100/80]
Open

    accepted_applications = application_letters.where(status: ApplicationLetter.statuses[:accepted])
Severity: Minor
Found in app/models/event.rb by rubocop

Use min_by(&:start_date) instead of min { |a, b| a.start_date <=> b.start_date }.
Open

    (date_ranges.min { |a,b| a.start_date <=> b.start_date }).start_date
Severity: Minor
Found in app/models/event.rb by rubocop

This cop identifies places where sort { |a, b| a.foo <=> b.foo } can be replaced by sort_by(&:foo). This cop also checks max and min methods.

Example:

# bad
array.sort { |a, b| a.foo <=> b.foo }
array.max { |a, b| a.foo <=> b.foo }
array.min { |a, b| a.foo <=> b.foo }
array.sort { |a, b| a[:foo] <=> b[:foo] }

# good
array.sort_by(&:foo)
array.sort_by { |v| v.foo }
array.sort_by do |var|
  var.foo
end
array.max_by(&:foo)
array.min_by(&:foo)
array.sort_by { |a| a[:foo] }

Use %i or %I for an array of symbols.
Open

      can [:index, :show], Profile
Severity: Minor
Found in app/models/ability.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]

Use && instead of and.
Open

    if birth_date.present? and birth_date > Date.current
Severity: Minor
Found in app/models/profile.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

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

    street_name + ", " + zip_code + " " +  city + ", " + state + ", " + country
Severity: Minor
Found in app/models/profile.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"

Line is too long. [114/80]
Open

  # Returns the number of accepted applications from the user without counting status of current event application
Severity: Minor
Found in app/models/user.rb by rubocop

Do not use parentheses for method calls with no arguments.
Open

    ApplicationLetter.where(user_id: id, status: false).where.not(event: event).count()
Severity: Minor
Found in app/models/user.rb by rubocop

This cop checks for unwanted parentheses in parameterless method calls.

Example:

# bad
object.some_method()

# good
object.some_method
Severity
Category
Status
Source
Language