Skip to content

Add a ruby linter - rubocop or standardrb #381

@experimatt

Description

@experimatt

This is in progress. After auto-fixing, there are still 79 violations that need attention.

See PR: #391

$ bundle exec standardrb

standard: Use Ruby Standard Style (https://github.com/standardrb/standard)
  app/admin/rooms.rb:33:9: Style/RedundantInterpolation: Prefer `to_s` over string interpolation.
  app/controllers/application_controller.rb:12:30: Style/SafeNavigation: Use safe navigation (`&.`) instead of checking if an object exists before calling the method.
  app/controllers/participants_controller.rb:84:7: Style/IdenticalConditionalBranches: Move `redirect_to root_path` out of the conditional.
  app/controllers/participants_controller.rb:87:7: Style/IdenticalConditionalBranches: Move `redirect_to root_path` out of the conditional.
  app/helpers/schedules_helper.rb:27:19: Style/SlicingWithRange: Prefer `[split..]` over `[split..-1]`.
  app/mailers/notifier.rb:1:7: Rails/MailerName: Mailer should end with `Mailer` suffix.
  app/mailers/notifier.rb:1:18: Rails/ApplicationMailer: Mailers should subclass `ApplicationMailer`.
  app/mailers/notifier.rb:7:21: Rails/TimeZone: Do not use `Time.now` without zone. Use one of `Time.zone.now`, `Time.current`, `Time.now.in_time_zone`, `Time.now.utc`, `Time.now.getlocal`, `Time.now.xmlschema`, `Time.now.iso8601`, `Time.now.jisx0301`, `Time.now.rfc3339`, `Time.now.httpdate`, `Time.now.to_i`, `Time.now.to_f` instead.
  app/models/admin_user.rb:1:19: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/attendance.rb:1:20: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/attendance.rb:7:26: Rails/RedundantPresenceValidationOnBelongsTo: Remove explicit presence validation for `session_id`.
  app/models/attendance.rb:8:30: Rails/RedundantPresenceValidationOnBelongsTo: Remove explicit presence validation for `participant_id`.
  app/models/categorization.rb:1:24: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/category.rb:1:18: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/code_of_conduct_agreement.rb:1:32: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/event.rb:1:15: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/event.rb:38:34: Style/RedundantSort: Use `min_by` instead of `sort_by...first`.
  app/models/event.rb:59:26: Lint/AssignmentInCondition: Wrap assignment in parentheses if intentional
  app/models/level.rb:1:15: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/markdown_content.rb:1:25: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/participant.rb:1:21: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/presentation.rb:4:22: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/presentation.rb:8:23: Rails/RedundantPresenceValidationOnBelongsTo: Remove explicit presence validation for `session`.
  app/models/presentation.rb:9:30: Rails/RedundantPresenceValidationOnBelongsTo: Remove explicit presence validation for `participant_id`.
  app/models/presenter_timeslot_restriction.rb:1:38: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/presenter_timeslot_restriction.rb:5:27: Rails/RedundantPresenceValidationOnBelongsTo: Remove explicit presence validation for `timeslot_id`.
  app/models/presenter_timeslot_restriction.rb:6:30: Rails/RedundantPresenceValidationOnBelongsTo: Remove explicit presence validation for `participant_id`.
  app/models/room.rb:1:14: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/room.rb:9:24: Rails/RedundantPresenceValidationOnBelongsTo: Remove explicit presence validation for `event_id`.
  app/models/room.rb:11:3: Rails/UniqueValidationWithoutIndex: Uniqueness validation should have a unique index on the database column.
  app/models/session.rb:1:17: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/session.rb:34:24: Rails/RedundantPresenceValidationOnBelongsTo: Remove explicit presence validation for `event_id`.
  app/models/session.rb:35:30: Rails/RedundantPresenceValidationOnBelongsTo: Remove explicit presence validation for `participant_id`.
  app/models/session.rb:121:26: Rails/WhereEquals: Use `where(id: recommended.map { |r| r[1] })` instead of manually constructing SQL.
  app/models/session.rb:121:58: Rails/Pluck: Prefer `pluck(1)` over `map { |r| r[1] }`.
  app/models/session.rb:150:8: Rails/WhereEquals: Use `where(session_id: sessions_by_id.keys)` instead of manually constructing SQL.
  app/models/settings.rb:1:18: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/settings.rb:117:14: Rails/TimeZone: Do not use `Time.parse` without zone. Use one of `Time.zone.parse`, `Time.current`, `Time.parse.in_time_zone`, `Time.parse.utc`, `Time.parse.getlocal`, `Time.parse.xmlschema`, `Time.parse.iso8601`, `Time.parse.jisx0301`, `Time.parse.rfc3339`, `Time.parse.httpdate`, `Time.parse.to_i`, `Time.parse.to_f` instead.
  app/models/settings.rb:118:14: Rails/TimeZone: Do not use `Time.parse` without zone. Use one of `Time.zone.parse`, `Time.current`, `Time.parse.in_time_zone`, `Time.parse.utc`, `Time.parse.getlocal`, `Time.parse.xmlschema`, `Time.parse.iso8601`, `Time.parse.jisx0301`, `Time.parse.rfc3339`, `Time.parse.httpdate`, `Time.parse.to_i`, `Time.parse.to_f` instead.
  app/models/settings.rb:125:27: Rails/TimeZone: Do not use `Time.parse` without zone. Use one of `Time.zone.parse`, `Time.current`, `Time.parse.in_time_zone`, `Time.parse.utc`, `Time.parse.getlocal`, `Time.parse.xmlschema`, `Time.parse.iso8601`, `Time.parse.jisx0301`, `Time.parse.rfc3339`, `Time.parse.httpdate`, `Time.parse.to_i`, `Time.parse.to_f` instead.
  app/models/settings.rb:126:25: Rails/TimeZone: Do not use `Time.parse` without zone. Use one of `Time.zone.parse`, `Time.current`, `Time.parse.in_time_zone`, `Time.parse.utc`, `Time.parse.getlocal`, `Time.parse.xmlschema`, `Time.parse.iso8601`, `Time.parse.jisx0301`, `Time.parse.rfc3339`, `Time.parse.httpdate`, `Time.parse.to_i`, `Time.parse.to_f` instead.
  app/models/timeslot.rb:1:18: Rails/ApplicationRecord: Models should subclass `ApplicationRecord`.
  app/models/timeslot.rb:8:24: Rails/RedundantPresenceValidationOnBelongsTo: Remove explicit presence validation for `event_id`.
  lib/scheduling/context.rb:69:7: Rails/Output: Do not write to stdout. Use Rails's logger if you want to log.
  lib/scheduling/context.rb:69:74: Style/LineEndConcatenation: Use `\` instead of `+` to concatenate multiline strings.
  lib/scheduling/schedule.rb:129:7: Rails/Output: Do not write to stdout. Use Rails's logger if you want to log.
  lib/scheduling/schedule.rb:179:11: Rails/Output: Do not write to stdout. Use Rails's logger if you want to log.
  lib/scheduling/schedule.rb:182:13: Rails/Output: Do not write to stdout. Use Rails's logger if you want to log.
  lib/scheduling/schedule.rb:182:55: Style/LineEndConcatenation: Use `\` instead of `+` to concatenate multiline strings.
  lib/scheduling/schedule.rb:200:9: Rails/Output: Do not write to stdout. Use Rails's logger if you want to log.
  lib/scheduling/schedule.rb:201:9: Rails/Output: Do not write to stdout. Use Rails's logger if you want to log.
  lib/scheduling/schedule.rb:203:11: Rails/Output: Do not write to stdout. Use Rails's logger if you want to log.
  lib/scheduling/schedule.rb:205:9: Rails/Output: Do not write to stdout. Use Rails's logger if you want to log.
  lib/scheduling/session_set.rb:19:7: Style/SafeNavigation: Use safe navigation (`&.`) instead of checking if an object exists before calling the method.
  lib/tasks/app.rake:114:17: Rails/FindEach: Use `find_each` instead of `each`.
  lib/tasks/app.rake:229:42: Performance/Detect: Use `find` instead of `select.first`.
  lib/tasks/app.rake:231:102: Style/LineEndConcatenation: Use `\` instead of `+` to concatenate multiline strings.
  lib/tasks/app.rake:239:14: Lint/MixedRegexpCaptureTypes: Do not mix named captures and numbered captures in a Regexp literal.
  lib/tasks/app.rake:294:12: Style/RedundantInterpolation: Prefer `to_s` over string interpolation.
  lib/tasks/app.rake:295:48: Rails/WhereEquals: Use `where(event_id: event.id)` instead of manually constructing SQL.
  lib/tasks/app.rake:301:67: Style/LineEndConcatenation: Use `\` instead of `+` to concatenate multiline strings.
  lib/tasks/app.rake:302:39: Style/LineEndConcatenation: Use `\` instead of `+` to concatenate multiline strings.
  lib/tasks/app.rake:310:5: Style/GlobalStdStream: Use `$stdout` instead of `STDOUT`.
  lib/tasks/app.rake:312:13: Style/GlobalStdStream: Use `$stdin` instead of `STDIN`.
  lib/tasks/app.rake:315:7: Style/GlobalStdStream: Use `$stdout` instead of `STDOUT`.
  lib/tasks/app.rake:317:7: Style/GlobalStdStream: Use `$stdout` instead of `STDOUT`.
  lib/tasks/app.rake:358:15: Style/GlobalStdStream: Use `$stdout` instead of `STDOUT`.
  lib/tasks/app.rake:391:108: Style/LineEndConcatenation: Use `\` instead of `+` to concatenate multiline strings.
  lib/tasks/app.rake:394:53: Style/LineEndConcatenation: Use `\` instead of `+` to concatenate multiline strings.
  lib/tasks/app.rake:395:158: Style/LineEndConcatenation: Use `\` instead of `+` to concatenate multiline strings.
  lib/tasks/app.rake:414:19: Style/HashConversion: Prefer `ary.to_h` to `Hash[ary]`.
  lib/tasks/app.rake:426:25: Style/GlobalStdStream: Use `$stdin` instead of `STDIN`.
  lib/tasks/app.rake:462:37: Performance/Count: Use `count` instead of `select...count`.
  lib/tasks/app.rake:481:38: Performance/Detect: Use `find` instead of `select.first`.
  lib/tasks/app.rake:492:39: Rails/TimeZone: Do not use `Time.now` without zone. Use one of `Time.zone.now`, `Time.current`, `Time.now.in_time_zone`, `Time.now.utc`, `Time.now.getlocal`, `Time.now.xmlschema`, `Time.now.iso8601`, `Time.now.jisx0301`, `Time.now.rfc3339`, `Time.now.httpdate`, `Time.now.to_i`, `Time.now.to_f` instead.
  lib/tasks/app.rake:619:28: Lint/AssignmentInCondition: Wrap assignment in parentheses if intentional
  spec/controllers/participants_controller_spec.rb:70:91: Rails/TimeZone: Do not use `Time.now` without zone. Use one of `Time.zone.now`, `Time.current`, `Time.now.in_time_zone`, `Time.now.utc`, `Time.now.getlocal`, `Time.now.xmlschema`, `Time.now.iso8601`, `Time.now.jisx0301`, `Time.now.rfc3339`, `Time.now.httpdate`, `Time.now.to_i`, `Time.now.to_f` instead.
  spec/features/interest_gathering_spec.rb:5:127: Rails/TimeZone: Do not use `Time.now` without zone. Use one of `Time.zone.now`, `Time.current`, `Time.now.in_time_zone`, `Time.now.utc`, `Time.now.getlocal`, `Time.now.xmlschema`, `Time.now.iso8601`, `Time.now.jisx0301`, `Time.now.rfc3339`, `Time.now.httpdate`, `Time.now.to_i`, `Time.now.to_f` instead.
  spec/features/manage_your_profile_spec.rb:5:55: Rails/TimeZone: Do not use `Time.now` without zone. Use one of `Time.zone.now`, `Time.current`, `Time.now.in_time_zone`, `Time.now.utc`, `Time.now.getlocal`, `Time.now.xmlschema`, `Time.now.iso8601`, `Time.now.jisx0301`, `Time.now.rfc3339`, `Time.now.httpdate`, `Time.now.to_i`, `Time.now.to_f` instead.
  spec/features/sign_in_and_out_spec.rb:4:78: Rails/TimeZone: Do not use `Time.now` without zone. Use one of `Time.zone.now`, `Time.current`, `Time.now.in_time_zone`, `Time.now.utc`, `Time.now.getlocal`, `Time.now.xmlschema`, `Time.now.iso8601`, `Time.now.jisx0301`, `Time.now.rfc3339`, `Time.now.httpdate`, `Time.now.to_i`, `Time.now.to_f` instead.
  spec/models/event_spec.rb:4:50: Rails/Date: Do not use `Date.today` without zone. Use `Time.zone.today` instead.
  spec/models/settings_spec.rb:31:96: Style/LineEndConcatenation: Use `\` instead of `+` to concatenate multiline strings.
  spec/spec_helper.rb:19:1: Rails/RootPathnameMethods: `Rails.root` is a `Pathname`, so you can use `Rails.root.glob("spec/support/**/*.rb")`.
standard: Run `standardrb --fix` to fix up to 79 problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions