From 1633caccbad2327543c411d931335786930ed670 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Wed, 31 May 2023 19:28:40 +0200 Subject: [PATCH] Add Rubocop and run Linters on Test Action (#56) Add Rubocup and Eslint runs on test --- .github/workflows/test.yml | 13 + .rubocop.yml | 227 ++++++++++++++++++ Frontend/src/index.jsx | 2 +- .../register/components/RegistrationPanel.jsx | 2 +- Gemfile | 30 +-- Rakefile | 4 +- app/channels/application_cable/channel.rb | 2 + app/channels/application_cable/connection.rb | 2 + app/controllers/application_controller.rb | 2 + app/controllers/healthcheck_controller.rb | 4 +- app/controllers/metrics_controller.rb | 14 +- app/controllers/registration_controller.rb | 130 +++++----- app/helpers/competition_api.rb | 3 +- app/helpers/competitor_api.rb | 3 +- app/jobs/application_job.rb | 2 + app/mailers/application_mailer.rb | 6 +- app/models/application_record.rb | 2 + app/worker/queue_poller.rb | 14 +- app/worker/registration_processor.rb | 38 +-- bin/bundle | 46 ++-- bin/rails | 8 +- bin/rake | 6 +- bin/setup | 18 +- config.ru | 4 +- config/application.rb | 6 +- config/boot.rb | 8 +- config/environment.rb | 4 +- config/environments/development.rb | 9 +- config/environments/production.rb | 20 +- config/environments/test.rb | 8 +- config/initializers/_vault.rb | 27 +-- config/initializers/aws.rb | 7 +- config/initializers/cors.rb | 14 +- .../initializers/filter_parameter_logging.rb | 6 +- config/initializers/inflections.rb | 1 + config/puma.rb | 14 +- config/routes.rb | 2 + db/seeds.rb | 22 +- .../application_cable/connection_test.rb | 22 +- .../healthcheck_controller_test.rb | 4 +- .../registration_controller_test.rb | 3 +- test/test_helper.rb | 22 +- 42 files changed, 545 insertions(+), 236 deletions(-) create mode 100644 .rubocop.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aef74773..81fe4ee8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,5 +11,18 @@ jobs: RACK_ENV: test steps: - uses: actions/checkout@v3 + - name: Set up Ruby # Only install ruby to get Rubocop + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2.2' + - name: Lint with Rubocop + run: | + gem install rubocop + rubocop + - name: Lint with Eslint + run: | + cd ./Frontend + npm install + npm run lint - name: Start containers run: docker compose -f "docker-compose.test.yml" up wca_registration_handler --abort-on-container-exit diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..03b29316 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,227 @@ +AllCops: + TargetRubyVersion: 3.2.2 + DisplayCopNames: true + NewCops: enable + Exclude: + - 'node_modules/**/*' + - 'Frontend/**/*' + - 'bin/**/*' + - 'vendor/**/*' + +Bundler/OrderedGems: + Enabled: false + +Lint/EmptyWhen: + Enabled: false + +Lint/UnusedBlockArgument: + Enabled: false + +Lint/UnusedMethodArgument: + Enabled: false + +Naming/AccessorMethodName: + Enabled: false + +Style/Alias: + Enabled: false + +Style/EmptyMethod: + EnforcedStyle: expanded + +Style/RedundantSelf: + Enabled: false + +Style/SafeNavigation: + Enabled: false + +Style/StringLiterals: + # EnforcedStyle: double_quotes + Enabled: false + +Style/TrailingCommaInArguments: + # If `comma`, the cop requires a comma after the last argument, but only for + # parenthesized method calls where each argument is on its own line. + # If `consistent_comma`, the cop requires a comma after the last argument, + # for all parenthesized method calls with arguments. + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInArrayLiteral: + # If `comma`, the cop requires a comma after the last argument, but only for + # parenthesized method calls where each argument is on its own line. + # If `consistent_comma`, the cop requires a comma after the last argument, + # for all parenthesized method calls with arguments. + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInHashLiteral: + # If `comma`, the cop requires a comma after the last item in an array or + # hash, but only when each item is on its own line. + # If `consistent_comma`, the cop requires a comma after the last item of all + # non-empty array and hash literals. + EnforcedStyleForMultiline: comma + +Style/GuardClause: + Enabled: false + +Metrics/AbcSize: + Enabled: false + +Metrics/BlockLength: + Enabled: false + +Metrics/BlockNesting: + Enabled: false + +Metrics/ClassLength: + Enabled: false + +Metrics/CyclomaticComplexity: + Max: 23 + +Metrics/ParameterLists: + Max: 5 + CountKeywordArgs: false + +Metrics/PerceivedComplexity: + Max: 25 + +Layout/LineLength: + Max: 245 + +Metrics/MethodLength: + Enabled: false + +Metrics/ModuleLength: + Enabled: false + +Naming/MemoizedInstanceVariableName: + Enabled: false + +Style/AccessModifierDeclarations: + Enabled: false + +Style/AsciiComments: + Enabled: false + +Style/BlockDelimiters: + Enabled: false + +Style/ClassAndModuleChildren: + Enabled: false + +Style/ClassVars: + Enabled: false + +Style/ConditionalAssignment: + Enabled: false + +Style/Documentation: + Enabled: false + +Style/DoubleNegation: + Enabled: false + +Style/EmptyElse: + EnforcedStyle: empty + +Style/IfInsideElse: + Enabled: false + +Style/IfUnlessModifier: + Enabled: false + +Style/InverseMethods: + Enabled: false + +Style/Lambda: + Enabled: false + +Style/MultilineBlockChain: + Enabled: false + +Style/NegatedIf: + Enabled: false + +Style/Next: + Enabled: false + +Style/NumericPredicate: + Enabled: false + +Style/PercentLiteralDelimiters: + Enabled: false + +Style/PerlBackrefs: + Enabled: false + +Style/RaiseArgs: + EnforcedStyle: compact + +Style/RedundantParentheses: + Enabled: false + +Style/SignalException: + EnforcedStyle: only_raise + +Layout/SpaceAroundOperators: + Enabled: false + +Layout/IndentationConsistency: + EnforcedStyle: indented_internal_methods + +Style/StringLiteralsInInterpolation: + Enabled: false + +Style/SymbolArray: + Enabled: false + +Style/WordArray: + Enabled: false + +Style/SymbolProc: + Enabled: false + +Naming/PredicateName: + Enabled: false + +Naming/BlockParameterName: + Enabled: false + +Naming/MethodParameterName: + Enabled: false + +Style/YodaCondition: + Enabled: false + +Style/FormatStringToken: + Enabled: false + +Layout/EmptyLineAfterGuardClause: + Enabled: false + +Lint/EmptyFile: + Exclude: + - 'db/seeds.rb' + +# We have too many event IDs and Comp Years with numbers in them +Naming/VariableNumber: + Enabled: false + +# If an external library requires us to use terms like "blacklist", +# we have no choice but to follow their conventions until they update +Naming/InclusiveLanguage: + Exclude: + - 'config/**/*' + +Style/OpenStructUse: + Exclude: + - 'spec/lib/middlewares/warden_user_logger_spec.rb' + +Style/HashSyntax: + EnforcedShorthandSyntax: never + +# These AWS Clients are set in the initializer +Style/GlobalVars: + AllowedVariables: + - $sqs + - $dynamodb \ No newline at end of file diff --git a/Frontend/src/index.jsx b/Frontend/src/index.jsx index cf22100f..aa1f4413 100644 --- a/Frontend/src/index.jsx +++ b/Frontend/src/index.jsx @@ -3,8 +3,8 @@ import '@thewca/wca-components/dist/index.esm.css' import React from 'react' import { createRoot } from 'react-dom/client' import { createBrowserRouter, Link, RouterProvider } from 'react-router-dom' -import Registrations from './pages/registrations' import Register from './pages/register' +import Registrations from './pages/registrations' const router = createBrowserRouter([ { diff --git a/Frontend/src/pages/register/components/RegistrationPanel.jsx b/Frontend/src/pages/register/components/RegistrationPanel.jsx index 12c17715..8cf89e89 100644 --- a/Frontend/src/pages/register/components/RegistrationPanel.jsx +++ b/Frontend/src/pages/register/components/RegistrationPanel.jsx @@ -37,7 +37,7 @@ export default function RegistrationPanel() { handleEventSelection={handleEventSelection} events={EVENTS} initialSelected={[]} - size={'2x'} + size="2x" />