Files
ubicloud/.rubocop.yml
geemus 6d6b8317c5 Enable committee openapi schema checking in test and production
Committee is rack middleware that validates requests and responses for
adherence to an openapi specification.  It will limit the kind of
(possibly malicious) input to the API part of the program.  And, it
because it checks the test suite, and we have a 100% branch coverage
policy covering routes, fixing schema problems will keep the openapi
specification up to date as people add features.

committee already detected some mistakes, such as being too relaxed
about content types, in 793b61f260.

Applying committee obsoletes some validation code, but not a lot: at
least some validations are also called from the web application,
rather than the API.  It's not clear to me how well these can be
converged to reduce code.

However, it does obsolete several validation-related API *tests* that
were rolled in with API application testing: now, the entire API is
covered in a consistent way for that kind of thing: parsable JSON,
missing fields, extra fields, etc.

Here's a measurement of the overhead of checking all those requests
for schema conformance in test: it's not really measurable on a
whole-suite basis.

Without:

    > hyperfine -w 3 -- 'bundle exec rspec'
    Benchmark 1: bundle exec rspec
      Time (mean ± σ):     29.790 s ±  2.182 s    [User: 19.139 s, System: 1.391 s]
      Range (min … max):   26.130 s … 33.358 s    10 runs

With:

    > hyperfine -w 3 -- 'bundle exec rspec'
    Benchmark 1: bundle exec rspec
      Time (mean ± σ):     28.378 s ±  1.483 s    [User: 18.705 s, System: 1.364 s]
      Range (min … max):   25.428 s … 30.742 s    10 runs

No, that's not swapped. There's just something else going on that
makes noise larger than the margin of error.
2024-12-03 15:29:16 -08:00

83 lines
1.2 KiB
YAML

# Modified from https://www.fastruby.io/blog/ruby/code-quality/how-we-use-rubocop-and-standardrb.html
require:
- rubocop-capybara
- rubocop-erb
- rubocop-performance
- rubocop-rake
- rubocop-rspec
- rubocop-sequel
- standard
inherit_gem:
standard: config/base.yml
AllCops:
TargetRubyVersion: 3.2
NewCops: enable
Exclude:
- public/**/*
- vendor/**/*
- node_modules/**/*
RSpec:
Enabled: true
Performance:
Enabled: true
Rake:
Enabled: true
Sequel:
Enabled: true
RSpec/DescribeMethod:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: true
Style/BlockComments:
Enabled: false
Layout/HeredocIndentation:
Enabled: false
Layout/SpaceInsideHashLiteralBraces:
Exclude:
- 'views/**/*.erb'
RSpec/AnyInstance:
Enabled: false
RSpec/ExampleLength:
Enabled: false
RSpec/MultipleExpectations:
Enabled: false
RSpec/StubbedMock:
Enabled: false
RSpec/MessageSpies:
Enabled: false
RSpec/SubjectStub:
Enabled: false
RSpec/ExpectInHook:
Enabled: false
RSpec/InstanceVariable:
Enabled: false
RSpec/SpecFilePathFormat:
Exclude:
- 'spec/routes/**/*.rb'
Sequel/IrreversibleMigration:
Enabled: false
Capybara/ClickLinkOrButtonStyle:
EnforcedStyle: strict