diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 000000000..9b87a07a6 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,100 @@ +name: .github/workflows/verify.yml + +on: [push] + +jobs: + # + # + # Unit Tests + # + # + unit_tests: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - uses: actions/checkout@v2 + + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Install PostgreSQL client + run: | + sudo apt-get -yqq install libpq-dev + + - name: Build App + env: + PGHOST: localhost + PGUSER: postgres + PGPASSWORD: postgres + RAILS_ENV: test + run: | + bin/rails db:setup + + - name: Prep assets + env: + PGHOST: localhost + PGUSER: postgres + PGPASSWORD: postgres + RAILS_ENV: test + run: | + bundle install && yarn install && yarn build:css && yarn build + + - name: Execute unit tests + env: + PGHOST: localhost + PGUSER: postgres + PGPASSWORD: postgres + RAILS_ENV: test + run: | + ./bin/rails test + + # + # + # Rubocop + # + # + rubocop: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: ruby/setup-ruby@v1 + + - name: Run rubocop + run: | + gem install rubocop + rubocop app/ + + # + # + # Reek + # + # + reek: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: ruby/setup-ruby@v1 + + - name: Run Reek + run: | + gem install reek + reek app/ diff --git a/.reek.yml b/.reek.yml new file mode 100644 index 000000000..753141b40 --- /dev/null +++ b/.reek.yml @@ -0,0 +1,32 @@ +detectors: + IrresponsibleModule: + enabled: false + DuplicateMethodCall: + enabled: false + +exclude_paths: + - ./**/example* + +# from https://github.com/troessner/reek#working-with-rails +directories: + "app/controllers": + IrresponsibleModule: + enabled: false + NestedIterators: + max_allowed_nesting: 2 + UnusedPrivateMethod: + enabled: false + InstanceVariableAssumption: + enabled: false + "app/helpers": + IrresponsibleModule: + enabled: false + UtilityFunction: + enabled: false + "app/mailers": + InstanceVariableAssumption: + enabled: false + "app/models": + InstanceVariableAssumption: + enabled: false +# from https://github.com/troessner/reek#working-with-rails diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 000000000..fe867842e --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,3 @@ +inherit_from: .rubocop_todo.yml +Style/Documentation: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 000000000..9f3ca0e65 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,95 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-07-30 00:15:29 UTC using RuboCop version 1.55.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: around, only_before +Layout/EmptyLinesAroundAccessModifier: + Exclude: + - 'app/controllers/examples_controller.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, indented_internal_methods +Layout/IndentationConsistency: + Exclude: + - 'app/controllers/examples_controller.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Width, AllowedPatterns. +Layout/IndentationWidth: + Exclude: + - 'app/controllers/examples_controller.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceInsidePercentLiteralDelimiters: + Exclude: + - 'app/controllers/examples_controller.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Lint/RedundantCopDisableDirective: + Exclude: + - 'app/models/experiment.rb' + +# Offense count: 6 +# Configuration parameters: AllowedConstants. +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'app/controllers/examples_controller.rb' + - 'app/helpers/application_helper.rb' + - 'app/helpers/examples_helper.rb' + - 'app/mailers/application_mailer.rb' + - 'app/models/application_record.rb' + - 'app/models/user.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: compact, expanded +Style/EmptyMethod: + Exclude: + - 'app/controllers/examples_controller.rb' + +# Offense count: 14 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Exclude: + - 'app/channels/application_cable/channel.rb' + - 'app/channels/application_cable/connection.rb' + - 'app/controllers/application_controller.rb' + - 'app/controllers/examples_controller.rb' + - 'app/helpers/application_helper.rb' + - 'app/helpers/examples_helper.rb' + - 'app/jobs/application_job.rb' + - 'app/mailers/application_mailer.rb' + - 'app/models/application_record.rb' + - 'app/models/example.rb' + - 'app/models/user.rb' + - 'app/views/examples/_example.json.jbuilder' + - 'app/views/examples/index.json.jbuilder' + - 'app/views/examples/show.json.jbuilder' + +# Offense count: 7 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'app/controllers/examples_controller.rb' + - 'app/mailers/application_mailer.rb' + - 'app/views/examples/index.json.jbuilder' + - 'app/views/examples/show.json.jbuilder'