Skip to content

Commit

Permalink
Update project to use defra_ruby_style (#28)
Browse files Browse the repository at this point in the history
Updated the project to use our new shared gem for managing our ruby style rules.
  • Loading branch information
Cruikshanks authored Jan 8, 2019
1 parent 09ac4d4 commit ef35af3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 98 deletions.
100 changes: 3 additions & 97 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,97 +1,3 @@
AllCops:
TargetRubyVersion: 2.4
# Cop names are not displayed in offense messages by default. We find it
# useful to include this information so we can use it to investigate what the
# fix may be.
DisplayCopNames: true
# Style guide URLs are not displayed in offense messages by default. Again we
# find it useful to go straight to the documentation for a rule when
# investigating what the fix may be.
DisplayStyleGuide: true
Include:
- "**/*.gemspec"
- "**/*.rake"
- "**/*.rb"
- "**/Gemfile"
- "**/Rakefile"
- "**/config.ru"
Exclude:
# config contains standard files created when Rails is initialised and
# therefore they should be left as is
- "**/config/**/*"
# bin contains standard files created when Rails is initialised and
# therefore they should be left as is
- "**/bin/*"
# locally when we run rubocop it ignores the vendor folder but when running
# in Travis-CI it seems to include. This will stop this from happening
- "**/vendor/**/*"
## schema.rb is generated automatically based on migrations, so leave as is
- "**/db/schema.rb"
# Skip dummy application files as they're only used for testing purposes
- "spec/dummy/**/*"

# It is our opinion that code is easier to read if a white space is
# permitted between the initial declaration and the first statement. Ditto the
# last statement and the closing tag.
Layout/EmptyLinesAroundModuleBody:
Enabled: false
Layout/EmptyLinesAroundClassBody:
Enabled: false
Layout/EmptyLinesAroundBlockBody:
Enabled: false

# We felt as a team that the default size of 15 was too low, and blocked what to
# us are sound methods which would not add any value if broken up, for example
# composer type methods. Therefore we agreed to up the score to 30 to allow for
# these types of methods
Metrics/AbcSize:
Max: 30

# We don't feel it makes sense to split specs and factories over multiple files,
# or when in a context be forced to try and come up with slightly different ones
# in order to reduce the block length. Hence we exclude specs and factories from
# this rule.
# Shared examples are the same as specs, but don't have the _spec.rb extension
# hence they are listed separately
Metrics/BlockLength:
Exclude:
# We're not bothered about a gemspec file having long block length
- "*.gemspec"
- "**/spec/**/*_spec.rb"
- "**/spec/factories/**/*.rb"
- "**/spec/support/shared_examples/*.rb"

# We believe the default 80 characters is too restrictive and that lines can
# still be readable and maintainable when no more than 120 characters. This also
# allows us to maximise our screen space.
Metrics/LineLength:
Max: 120
Exclude:
- "**/spec/**/*_spec.rb"
- "**/spec/factories/**/*.rb"
- "**/spec/support/shared_examples/*.rb"

# We wish we were good enough to remain within the rubocop limit of 10 lines
# however we often just seem to tip over by a few lines. Hence we have chosen
# to bump it to 20.
Metrics/MethodLength:
Max: 20

# Spec files can be quite long, so we shouldn't be forced to break them up
# if it doesn't make sense.
Metrics/ModuleLength:
Exclude:
- "**/spec/**/*_spec.rb"
- "**/spec/factories/**/*.rb"
- "**/spec/support/shared_examples/*.rb"

# As long as the team commit to using well named classes for it should not be
# necessary to add top-level class documentation.
Style/Documentation:
Enabled: false

# There are no relative performance improvements using '' over "", therefore we
# believe there is more value in using "" for all strings irrespective of
# whether string interpolation is used
Style/StringLiterals:
EnforcedStyle: double_quotes
inherit_gem:
defra_ruby_style:
- default.yml
2 changes: 1 addition & 1 deletion os_map_ref.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Gem::Specification.new do |s|

s.required_ruby_version = ">= 2.4"

s.add_development_dependency "defra_ruby_style"
# Allows us to automatically generate the change log from the tags, issues,
# labels and pull requests on GitHub. Added as a dependency so all dev's have
# access to it to generate a log, and so they are using the same version.
Expand All @@ -34,6 +35,5 @@ Gem::Specification.new do |s|
s.add_development_dependency "github_changelog_generator"
s.add_development_dependency "rake"
s.add_development_dependency "rspec", "~> 3.8"
s.add_development_dependency "rubocop"
s.add_development_dependency "simplecov"
end

0 comments on commit ef35af3

Please sign in to comment.