BathHacked/energy-sparks

View on GitHub
.rubocop.yml

Summary

Maintainability
Test Coverage
inherit_from: .rubocop_todo.yml

## regenerate .rubocop_todo.yml after any changes to this config using:
## rubocop --auto-gen-config --exclude-limit=1000
AllCops:
  NewCops: disable
  SuggestExtensions: false
  Include:
    # RuboCop by default ignores files and directories starting with `.`, so they have to be listed explicitly
    - 'app/**/*.rb'
    - 'lib/**/*.rb'
    - 'spec/**/*.rb'
  Exclude:
    - 'app/services/schools/funding_status_lookup.rb'
    - 'lib/data_feeds/weather_underground_loader.rb'
    - 'lib/data_feeds/solar_pv_tuos_loader.rb'
    - 'lib/data_feeds/dark_sky_temperature_loader.rb'
    - 'lib/data_feeds/solar_pv_tuos_v2_loader.rb'
    - 'script/**/*'
    - 'node_modules/**/*'
    - 'node_modules/node-sass/src/libsass/script/spec'
    - 'log/**/*'
    - 'storage/**/*'
    - 'tmp/**/*'
    # exclude as these files are updated/managed by rails app:upgrade
    - bin/rails
    - bin/rake
    - bin/setup
    - bin/yarn
    - config/application.rb
    - config/boot.rb
    - config/environment.rb
    - config/environments/development.rb
    - config/environments/production.rb
    - config/environments/test.rb
    - config/initializers/backtrace_silencers.rb
    - config/initializers/content_security_policy.rb
    - config/initializers/filter_parameter_logging.rb
    - config/initializers/new_framework_defaults_6_1.rb
    - config/initializers/permissions_policy.rb
    - config/puma.rb
    - config/routes.rb
require:
  - rubocop-rails
  - rubocop-performance
  - rubocop-rspec
# - rubocop-capybara
# - rubocop-factory_bot

Rails/DynamicFindBy:
  Enabled: false
Rails/Output:
  Enabled: false
Rails/SkipsModelValidations:
  Enabled: false
Rails/HasAndBelongsToMany:
  Enabled: false
Rails/Presence:
  Enabled: false
Rails/InverseOf:
  Enabled: false
Rails/HasManyOrHasOneDependent:
  Enabled: false
Rails/LexicallyScopedActionFilter:
  Enabled: false
Rails/Blank:
  Enabled: false
Rails/FilePath:
  Enabled: false
Rails/Delegate:
  Enabled: false
Rails/HelperInstanceVariable:
  Enabled: false
Rails/OutputSafety:
  Enabled: false
Rails/Validation:
  Enabled: false
Rails/EnumHash:
  Enabled: false
# added JLH 2021-05-13
Style/ConditionalAssignment:
  Enabled: false

# Performance cops
Performance/CompareWithBlock:
  Enabled: false

# General cops
Style/NumericPredicate:
  Enabled: false
Style/SymbolArray:
  Enabled: false
Style/SafeNavigation:
  Enabled: false
Style/IdenticalConditionalBranches:
  Enabled: false
Style/RescueStandardError:
  Enabled: false
Style/EmptyMethod:
  Enabled: false
Style/FormatStringToken:
  Enabled: false
Layout/MultilineMethodCallBraceLayout:
  Enabled: false
Layout/MultilineArrayBraceLayout:
  Enabled: false
Lint/BooleanSymbol:
  Enabled: false
Style/DateTime:
  Enabled: false
Style/InverseMethods:
  Enabled: false
Style/RedundantReturn:
  Enabled: false
Layout/SpaceInsideBlockBraces:
  Enabled: false
Layout/EmptyLineAfterGuardClause:
  Enabled: false
Layout/LineLength:
  Enabled: false
Style/Documentation:
  Enabled: false
Metrics/CyclomaticComplexity:
  Enabled: false
Metrics/AbcSize:
  Enabled: false
Metrics/ParameterLists:
  Enabled: false
Style/IfUnlessModifier:
  Enabled: false
Metrics/MethodLength:
  Enabled: false
Naming/AccessorMethodName:
  Enabled: false
Metrics/PerceivedComplexity:
  Enabled: false
Style/FrozenStringLiteralComment:
  Enabled: false
Naming/PredicateName:
  Enabled: false
Metrics/ClassLength:
  Enabled: false
Style/AsciiComments:
  Enabled: false
Style/GuardClause:
  Enabled: false
Style/ClassAndModuleChildren:
  Enabled: false
Metrics/ModuleLength:
  Enabled: false

# The following can all be fixed with self autocorrect
Layout/MultilineMethodCallIndentation:
  Enabled: false
Style/CommentAnnotation:
  Enabled: false
Style/RedundantSelf:
  Enabled: false
Layout/AccessModifierIndentation:
  Enabled: false
Style/Alias:
  Enabled: false
Style/Lambda:
  Enabled: false
Style/EachWithObject:
  Enabled: false
Layout/EmptyLines:
  Enabled: false
Layout/ArgumentAlignment:
  Enabled: false
Style/RedundantBegin:
  Enabled: false
Layout/HashAlignment:
  Enabled: false
Layout/FirstParameterIndentation:
  Enabled: false
Style/HashSyntax:
  Enabled: false
Layout/DotPosition:
  Enabled: false
Style/RaiseArgs:
  Enabled: false
Style/TrailingCommaInArguments:
  Enabled: false
Layout/SpaceAfterNot:
  Enabled: false
Style/PercentLiteralDelimiters:
  Enabled: false
Layout/ClosingParenthesisIndentation:
  Enabled: false
Layout/FirstHashElementIndentation:
  Enabled: false
Style/NonNilCheck:
  Enabled: false
Style/Next:
  Enabled: false
Style/RescueModifier:
  Enabled: false
Style/TrailingCommaInArrayLiteral:
  Enabled: false
Style/TrailingCommaInHashLiteral:
  Enabled: false
Naming/RescuedExceptionsVariableName:
  Enabled: false
Style/SelfAssignment:
  Enabled: false
Style/FormatString:
  Enabled: false

Layout/EmptyLinesAroundAttributeAccessor: # (new in 0.83)
  Enabled: false
Layout/SpaceAroundMethodCallOperator: # (new in 0.82)
  Enabled: true
Lint/BinaryOperatorWithIdenticalOperands: # (new in 0.89)
  Enabled: true
Lint/DeprecatedOpenSSLConstant: # (new in 0.84)
  Enabled: true
Lint/DuplicateElsifCondition: # (new in 0.88)
  Enabled: true
Lint/DuplicateRequire: # (new in 0.90)
  Enabled: true
Lint/DuplicateRescueException: # (new in 0.89)
  Enabled: true
Lint/EmptyConditionalBody: # (new in 0.89)
  Enabled: true
Lint/EmptyFile: # (new in 0.90)
  Enabled: true
Lint/FloatComparison: # (new in 0.89)
  Enabled: false
Lint/MissingSuper: # (new in 0.89)
  Enabled: false
Lint/MixedRegexpCaptureTypes: # (new in 0.85)
  Enabled: true
Lint/OutOfRangeRegexpRef: # (new in 0.89)
  Enabled: true
Lint/RaiseException: # (new in 0.81)
  Enabled: true
Lint/SelfAssignment: # (new in 0.89)
  Enabled: true
Lint/StructNewOverride: # (new in 0.81)
  Enabled: true
Lint/TopLevelReturnWithArgument: # (new in 0.89)
  Enabled: true
Lint/TrailingCommaInAttributeDeclaration: # (new in 0.90)
  Enabled: true
Lint/UnreachableLoop: # (new in 0.89)
  Enabled: true
Lint/UselessMethodDefinition: # (new in 0.90)
  Enabled: true
Style/AccessorGrouping: # (new in 0.87)
  Enabled: true
Style/ArrayCoercion: # (new in 0.88)
  Enabled: true
Style/BisectedAttrAccessor: # (new in 0.87)
  Enabled: true
Style/CaseLikeIf: # (new in 0.88)
  Enabled: false
Style/CombinableLoops: # (new in 0.90)
  Enabled: true
Style/ExplicitBlockArgument: # (new in 0.89)
  Enabled: false
Style/ExponentialNotation: # (new in 0.82)
  Enabled: true
Style/GlobalStdStream: # (new in 0.89)
  Enabled: true
Style/HashAsLastArrayItem: # (new in 0.88)
  Enabled: true
Style/HashEachMethods: # (new in 0.80)
  Enabled: true
Style/HashLikeCase: # (new in 0.88)
  Enabled: false
Style/HashTransformKeys: # (new in 0.80)
  Enabled: true
Style/HashTransformValues: # (new in 0.80)
  Enabled: true
Style/KeywordParametersOrder: # (new in 0.90)
  Enabled: false
Style/OptionalBooleanParameter: # (new in 0.89)
  Enabled: false
Style/RedundantAssignment: # (new in 0.87)
  Enabled: false
Style/RedundantFetchBlock: # (new in 0.86)
  Enabled: false
Style/RedundantFileExtensionInRequire: # (new in 0.88)
  Enabled: true
Style/RedundantRegexpCharacterClass: # (new in 0.85)
  Enabled: true
Style/RedundantRegexpEscape: # (new in 0.85)
  Enabled: false
Style/RedundantSelfAssignment: # (new in 0.90)
  Enabled: true
Style/SingleArgumentDig: # (new in 0.89)
  Enabled: true
Style/SlicingWithRange: # (new in 0.83)
  Enabled: false
Style/SoleNestedConditional: # (new in 0.89)
  Enabled: false
Style/StringConcatenation: # (new in 0.89)
  Enabled: false

Rails/ContentTag:
  Enabled: false
Rails/UniqueValidationWithoutIndex:
  Enabled: false
Performance/Detect:
  Enabled: false
Rails/RedundantForeignKey:
  Enabled: false

Rails/ActiveRecordCallbacksOrder: # (new in 2.7)
  Enabled: false
Rails/AfterCommitOverride: # (new in 2.8)
  Enabled: true
Rails/FindById: # (new in 2.7)
  Enabled: true
Rails/Inquiry: # (new in 2.7)
  Enabled: true
Rails/MailerName: # (new in 2.7)
  Enabled: true
Rails/MatchRoute: # (new in 2.7)
  Enabled: true
Rails/NegateInclude: # (new in 2.7)
  Enabled: false
Rails/Pluck: # (new in 2.7)
  Enabled: false
Rails/PluckInWhere: # (new in 2.7)
  Enabled: true
Rails/RenderInline: # (new in 2.7)
  Enabled: true
Rails/RenderPlainText: # (new in 2.7)
  Enabled: true
Rails/ShortI18n: # (new in 2.7)
  Enabled: true
Rails/SquishedSQLHeredocs: # (new in 2.8)
  Enabled: true
Rails/WhereExists: # (new in 2.7)
  Enabled: true
Rails/WhereNot: # (new in 2.8)
  Enabled: true
Performance/AncestorsInclude: # (new in 1.7)
  Enabled: true
Performance/BigDecimalWithNumericArgument: # (new in 1.7)
  Enabled: true
Performance/RedundantSortBlock: # (new in 1.7)
  Enabled: true
Performance/RedundantStringChars: # (new in 1.7)
  Enabled: true
Performance/ReverseFirst: # (new in 1.7)
  Enabled: true
Performance/SortReverse: # (new in 1.7)
  Enabled: true
Performance/Squeeze: # (new in 1.7)
  Enabled: true
Performance/StringInclude: # (new in 1.7)
  Enabled: false
Performance/Sum: # (new in 1.8)
  Enabled: false

Naming/VariableNumber:
  Enabled: false
Performance/CollectionLiteralInLoop:
  Enabled: true
Rails/Date:
  Enabled: true
Lint/RedundantCopDisableDirective:
  Enabled: false
Lint/RedundantCopEnableDirective:
  Enabled: false
Rails/RelativeDateConstant:
  Enabled: false
Style/ZeroLengthPredicate:
  Enabled: false
Style/NumericLiterals:
  Enabled: false
Performance/TimesMap:
  Enabled: false

### RSpec cops we're configuring for our project ###

RSpec/ChangeByZero:
  Enabled: false
RSpec/DescribedClass:
  Enabled: false
RSpec/LeadingSubject:
  Enabled: false
RSpec/ScatteredLet:
  Enabled: false
RSpec/NestedGroups:
  Enabled: false
RSpec/VariableName:
  AllowedPatterns:
    - _£_
RSpec/ScatteredSetup:
  Enabled: false
RSpec/ItBehavesLike:
  EnforcedStyle: 'it_behaves_like' # rather than 'it_should_behave_like'
RSpec/MultipleExpectations:
  Max: 12 # max expectations per test
  Exclude:
    - 'spec/helpers/application_helper_spec.rb'
    - 'spec/helpers/nav_helper_spec.rb'
    - 'spec/helpers/school_groups_helper_spec.rb'
    - 'spec/models/amr_reading_data_spec.rb'
    - 'spec/models/chart_data_values_spec.rb'
    - 'spec/services/amr/analytics_school_factory_spec.rb'
    - 'spec/services/maps/school_features_spec.rb'
    - 'spec/services/school_groups/comparisons_csv_generator_spec.rb'
    - 'spec/services/solar/low_carbon_hub_installation_factory_spec.rb'
    - 'spec/support/shared_examples/energy_tariff_editors.rb'
    - 'spec/support/shared_examples/energy_tariffs.rb'
    - 'spec/support/shared_examples/school_groups.rb'
    - 'spec/system/admin/activity_type_spec.rb'
    - 'spec/system/admin/alert_type_management_ratings_spec.rb'
    - 'spec/system/admin/school_creation_spec.rb'
    - 'spec/system/admin/school_groups_spec.rb'
    - 'spec/system/rtone_variant_installation_spec.rb'
    - 'spec/system/school_onboarding_spec.rb'
RSpec/AnyInstance:
  Enabled: false
RSpec/LetSetup:
  # often used in shared contexts allowing let to be overridden
  Enabled: false

### Things we're unlikely to fix: ###

Security/JSONLoad:
  Exclude:
    - 'spec/services/events/list_events_spec.rb'
Security/YAMLLoad:
  Exclude:
    - 'spec/system/admin/meter_attributes_spec.rb'
Naming/AsciiIdentifiers:
  Exclude: # excluding these are they have £ signs in method names
    - 'spec/models/meter_attribute_spec.rb'
    - 'spec/services/schools/advice/baseload_service_spec.rb'
    - 'spec/system/schools/advice_pages/hot_water_spec.rb'
Metrics/BlockLength:
  Exclude: # excluding route file as blocklength can be greater than default 25
    - 'config/route.rb'
Rails/FindEach:
  Exclude: # find_each does not work here
    - 'app/components/comparison_table_component.rb'