cloudfoundry/cloud_controller_ng

View on GitHub
.rubocop_cc.yml

Summary

Maintainability
Test Coverage
# Cloud Controller Specific Rubocop Config

require:
  - rubocop-sequel
  - rubocop-rails
  - rubocop-capybara
  - rubocop-factory_bot
  - rubocop-rspec
  - rubocop-rspec_rails
  - ./spec/linters/migration/add_constraint_name.rb
  - ./spec/linters/migration/include_string_size.rb
  - ./spec/linters/migration/require_primary_key.rb
  - ./spec/linters/match_requires_with_includes.rb
  - ./spec/linters/prefer_oj_over_other_json_libraries.rb

AllCops:
  TargetRubyVersion: 3.2
  Exclude:
    - errors/**/*
    - lib/diego/bbs/models/**/*
    - lib/locket/**/*
    - lib/logcache/v2/**/*
    - vendor/bundle/**/*
Layout/DotPosition:
  EnforcedStyle: trailing
Layout/FirstArrayElementIndentation:
  EnforcedStyle: consistent
Layout/SpaceAroundEqualsInParameterDefault:
  EnforcedStyle: no_space
Layout/EmptyLineBetweenDefs:
  EmptyLineBetweenClassDefs: false
Layout/LineLength:
  Max: 180
Lint/UnifiedInteger:
  Exclude:
    - db/migrations/**/*
Metrics/BlockLength:
  Exclude:
    - db/migrations/**/*
    - spec/**/*
    - lib/cloud_controller/config.rb
    - config/routes.rb
    - lib/tasks/db.rake
    - lib/tasks/jobs.rake
  Max: 50
Metrics/CyclomaticComplexity:
  Max: 12
Metrics/MethodLength:
  Max: 60
Metrics/ModuleLength:
  Max: 200
  Exclude:
    - spec/**/*
Migration/AddConstraintName: # Exclude for old Migrations
  Include:
    - 'db/migrations/**/*'
  Exclude:
    - !ruby/regexp /db/migrations/201([0-6]|70[1-6]).+\.rb$/
    - db/migrations/20221125134500_add_request_count_table.rb

Migration/IncludeStringSize: # Exclude for old Migrations
  Include:
    - 'db/migrations/**/*'
  Exclude:
    - !ruby/regexp /db/migrations/201([0-6]|70[1-6]|707[01]).+\.rb$/
    - db/migrations/20221125134500_add_request_count_table.rb

Migration/RequirePrimaryKey: # Exclude for old Migrations
  Include:
    - 'db/migrations/**/*'
  Exclude:
    - !ruby/regexp /db/migrations/201([0-7]|80[1-3]).+\.rb$/

Sequel/ConcurrentIndex: # Exclude for old Migrations
  Exclude:
    - !ruby/regexp /db/migrations/201([0-9]).+\.rb$/
    - !ruby/regexp /db/migrations/202([0-2]|30[0-7]).+\.rb$/
    - spec/**/*

Sequel/ColumnDefault: # Exclude for old Migrations
  Exclude:
    - !ruby/regexp /db/migrations/201([0-9]).+\.rb$/
    - !ruby/regexp /db/migrations/202([0-2]).+\.rb$/
    - spec/**/*

Rails/HttpPositionalArguments: # Breaks Code for specs as it`s not rails used there it`s a test framework(racktest)
  Exclude:
    - spec/**/*

Rails/Blank: # Alters logic if NilOrEmpty is true
  NilOrEmpty: false

Rails/Present:  # Alters logic if NotNilAndNotEmpty is true
  NotNilAndNotEmpty: false

Rails/Output: # Exclude for blobstore benchmark
  Exclude:
    - lib/cloud_controller/benchmark/blobstore.rb

Naming/FileName:
  Exclude:
    - Guardfile
Naming/MethodParameterName:
  MinNameLength: 3
  AllowNamesEndingInNumbers: true
  AllowedNames:
    - '_'
    - e
    - io
    - id
    - to
    - by
    - 'on'
    - in
    - at
    - ip
    - db
  ForbiddenNames: []
Style/Alias:
  EnforcedStyle: prefer_alias_method
Style/Encoding:
  Exclude:
    - "**/*.pb.rb"
Style/FormatString:
  EnforcedStyle: sprintf
Style/RaiseArgs:
  EnforcedStyle: compact
Style/HashSyntax:
  EnforcedShorthandSyntax: consistent
Style/ExpandPathArguments:
  Exclude:
    - 'db/migrations/20130911111938_encrypt_app_env_json.rb'
    - 'db/migrations/201805*'
Rails/DangerousColumnNames: # Disabled, in comparison to active_record we need to add the id column manually in sequel
  Enabled: false
Rails/SkipsModelValidations: # We don`t want any model at all in migrations and migration specs
  Enabled: true
  Exclude:
    - db/migrations/*
    - spec/migrations/*

#### ENABLED SECTION
Gemspec/DeprecatedAttributeAssignment:
  Enabled: true
Gemspec/DevelopmentDependencies:
  Enabled: true
Gemspec/RequireMFA:
  Enabled: true
Layout/LineContinuationLeadingSpace:
  Enabled: true
Layout/LineContinuationSpacing:
  Enabled: true
Layout/LineEndStringConcatenationIndentation:
  Enabled: true
Layout/SpaceBeforeBrackets:
  Enabled: true
Lint/AmbiguousAssignment:
  Enabled: true
Lint/AmbiguousOperatorPrecedence:
  Enabled: true
Lint/AmbiguousRange:
  Enabled: true
Lint/ConstantOverwrittenInRescue:
  Enabled: true
Lint/DeprecatedConstants:
  Enabled: true
Lint/DuplicateBranch:
  Enabled: true
Lint/DuplicateMagicComment:
  Enabled: true
Lint/DuplicateMatchPattern:
  Enabled: true
Lint/DuplicateRegexpCharacterClassElement:
  Enabled: true
Lint/EmptyBlock:
  Enabled: true
Lint/EmptyClass:
  Enabled: true
Lint/EmptyInPattern:
  Enabled: true
Lint/IncompatibleIoSelectWithFiberScheduler:
  Enabled: true
Lint/ItWithoutArgumentsInBlock:
  Enabled: true
Lint/LambdaWithoutLiteralBlock:
  Enabled: true
Lint/LiteralAssignmentInCondition:
  Enabled: true
Lint/MixedCaseRange:
  Enabled: true
Lint/NoReturnInBeginEndBlocks:
  Enabled: true
Lint/NonAtomicFileOperation:
  Enabled: true
Lint/NumberedParameterAssignment:
  Enabled: true
Lint/OrAssignmentToConstant:
  Enabled: true
Lint/RedundantDirGlobSort:
  Enabled: true
Lint/RedundantRegexpQuantifiers:
  Enabled: true
Lint/RefinementImportMethods:
  Enabled: true
Lint/RequireRangeParentheses:
  Enabled: true
Lint/RequireRelativeSelfPath:
  Enabled: true
Lint/SymbolConversion:
  Enabled: true
Lint/ToEnumArguments:
  Enabled: true
Lint/TripleQuotes:
  Enabled: true
Lint/UnexpectedBlockArity:
  Enabled: true
Lint/UnmodifiedReduceAccumulator:
  Enabled: true
Lint/UselessRescue:
  Enabled: true
Lint/UselessRuby2Keywords:
  Enabled: true
Metrics/CollectionLiteralLength:
  Enabled: true
Naming/BlockForwarding:
  Enabled: true
Security/CompoundHash:
  Enabled: true
Security/IoMethods:
  Enabled: true
Style/ArgumentsForwarding:
  Enabled: true
Style/ArrayIntersect:
  Enabled: true
Style/CollectionCompact:
  Enabled: true
Style/ComparableClamp:
  Enabled: true
Style/ConcatArrayLiterals:
  Enabled: true
Style/DataInheritance:
  Enabled: true
Style/DirEmpty:
  Enabled: true
Style/DocumentDynamicEvalDefinition:
  Enabled: true
Style/EmptyHeredoc:
  Enabled: true
Style/EndlessMethod:
  Enabled: true
Style/EnvHome:
  Enabled: true
Style/ExactRegexpMatch:
  Enabled: true
Style/FetchEnvVar:
  Enabled: true
Style/FileEmpty:
  Enabled: true
Style/FileRead:
  Enabled: true
Style/FileWrite:
  Enabled: true
Style/HashConversion:
  Enabled: true
Style/HashExcept:
  Enabled: true
Style/IfWithBooleanLiteralBranches:
  Enabled: true
Style/InPatternThen:
  Enabled: true
Style/MagicCommentFormat:
  Enabled: true
Style/MapCompactWithConditionalBlock:
  Enabled: true
Style/MapToHash:
  Enabled: true
Style/MapToSet:
  Enabled: true
Style/MinMaxComparison:
  Enabled: true
Style/MultilineInPatternThen:
  Enabled: true
Style/NegatedIfElseCondition:
  Enabled: true
Style/NestedFileDirname:
  Enabled: true
Style/NilLambda:
  Enabled: true
Style/NumberedParameters:
  Enabled: true
Style/NumberedParametersLimit:
  Enabled: true
Style/ObjectThen:
  Enabled: true
Style/OpenStructUse:
  Enabled: true
Style/OperatorMethodCall:
  Enabled: true
Style/QuotedSymbols:
  Enabled: true
Style/RedundantArgument:
  Enabled: true
Style/RedundantArrayConstructor:
  Enabled: true
Style/RedundantConstantBase:
  Enabled: true
Style/RedundantCurrentDirectoryInPath:
  Enabled: true
Style/RedundantDoubleSplatHashBraces:
  Enabled: true
Style/RedundantEach:
  Enabled: true
Style/RedundantFilterChain:
  Enabled: true
Style/RedundantHeredocDelimiterQuotes:
  Enabled: true
Style/RedundantInitialize:
  Enabled: true
Style/RedundantLineContinuation:
  Enabled: true
Style/RedundantRegexpArgument:
  Enabled: true
Style/RedundantRegexpConstructor:
  Enabled: true
Style/RedundantSelfAssignmentBranch:
  Enabled: true
Style/RedundantStringEscape:
  Enabled: true
Style/ReturnNilInPredicateMethodDefinition:
  Enabled: true
Style/SelectByRegexp:
  Enabled: true
Style/StringChars:
  Enabled: true
Style/SuperWithArgsParentheses:
  Enabled: true
Style/SwapValues:
  Enabled: true
Style/YAMLFileRead:
  Enabled: true
Rails/ActionControllerFlashBeforeRender:
  Enabled: true
Rails/ActionControllerTestCase:
  Enabled: true
Rails/ActionOrder:
  Enabled: true
Rails/ActiveRecordCallbacksOrder:
  Enabled: true
Rails/ActiveSupportOnLoad:
  Enabled: true
Rails/AddColumnIndex:
  Enabled: true
Rails/AfterCommitOverride:
  Enabled: true
Rails/AttributeDefaultBlockValue:
  Enabled: true
Rails/CompactBlank:
  Enabled: true
Rails/DeprecatedActiveModelErrorsMethods:
  Enabled: true
Rails/DotSeparatedKeys:
  Enabled: true
Rails/DuplicateAssociation:
  Enabled: true
Rails/DuplicateScope:
  Enabled: true
Rails/DurationArithmetic:
  Enabled: true
Rails/EagerEvaluationLogMessage:
  Enabled: true
Rails/EnvLocal:
  Enabled: true
Rails/ExpandedDateRange:
  Enabled: true
Rails/FindById:
  Enabled: true
Rails/FreezeTime:
  Enabled: true
Rails/I18nLazyLookup:
  Enabled: false
Rails/I18nLocaleAssignment:
  Enabled: false
Rails/I18nLocaleTexts:
  Enabled: false
Rails/IgnoredColumnsAssignment:
  Enabled: true
Rails/Inquiry:
  Enabled: true
Rails/MailerName:
  Enabled: true
Rails/MatchRoute:
  Enabled: true
Rails/MigrationClassName:
  Enabled: true
Rails/NegateInclude:
  Enabled: true
Rails/Pluck:
  Enabled: true
Rails/PluckInWhere:
  Enabled: true
Rails/RedundantPresenceValidationOnBelongsTo:
  Enabled: true
Rails/RedundantTravelBack:
  Enabled: true
Rails/RenderInline:
  Enabled: true
Rails/RenderPlainText:
  Enabled: true
Rails/ResponseParsedBody:
  Enabled: true
Rails/RootJoinChain:
  Enabled: true
Rails/RootPathnameMethods:
  Enabled: true
Rails/RootPublicPath:
  Enabled: true
Rails/SelectMap:
  Enabled: true
Rails/ShortI18n:
  Enabled: true
Rails/SquishedSQLHeredocs:
  Enabled: true
Rails/StripHeredoc:
  Enabled: true
Rails/ThreeStateBooleanColumn:
  Enabled: true
Rails/TimeZoneAssignment:
  Enabled: true
Rails/ToFormattedS:
  Enabled: true
Rails/ToSWithArgument:
  Enabled: true
Rails/TopLevelHashWithIndifferentAccess:
  Enabled: true
Rails/TransactionExitStatement:
  Enabled: true
Rails/UnusedIgnoredColumns:
  Enabled: true
Rails/UnusedRenderContent:
  Enabled: true
Rails/WhereEquals:
  Enabled: true
Rails/WhereExists:
  Enabled: true
Rails/WhereMissing:
  Enabled: true
Rails/WhereNot:
  Enabled: true
Rails/WhereNotWithMultipleConditions:
  Enabled: true
Capybara/ClickLinkOrButtonStyle:
  Enabled: false
Capybara/MatchStyle:
  Enabled: false
Capybara/NegationMatcher:
  Enabled: false
Capybara/RedundantWithinFind:
  Enabled: true
Capybara/SpecificActions:
  Enabled: false
Capybara/SpecificFinders:
  Enabled: false
Capybara/SpecificMatcher:
  Enabled: false
Capybara/RSpec/HaveSelector:
  Enabled: false
Capybara/RSpec/PredicateMatcher:
  Enabled: false
FactoryBot/AssociationStyle:
  Enabled: true
FactoryBot/ConsistentParenthesesStyle:
  Enabled: true
FactoryBot/ExcessiveCreateList:
  Enabled: true
FactoryBot/FactoryAssociationWithStrategy:
  Enabled: true
FactoryBot/FactoryNameStyle:
  Enabled: true
FactoryBot/IdSequence:
  Enabled: true
FactoryBot/RedundantFactoryOption:
  Enabled: true
FactoryBot/SyntaxMethods:
  Enabled: true
RSpec/BeEmpty:
  Enabled: true
RSpec/BeEq:
  Enabled: true
RSpec/BeNil:
  Enabled: true
RSpec/ChangeByZero:
  Enabled: true
RSpec/ContainExactly:
  Enabled: true
RSpec/DuplicatedMetadata:
  Enabled: true
RSpec/EmptyMetadata:
  Enabled: true
RSpec/Eq:
  Enabled: true
RSpec/ExcessiveDocstringSpacing:
  Enabled: true
RSpec/IdenticalEqualityAssertion:
  Enabled: true
RSpec/IndexedLet:
  Enabled: true
RSpec/MatchArray:
  Enabled: true
RSpec/MetadataStyle:
  Enabled: true
RSpec/NoExpectationExample:
  Enabled: true
RSpec/PendingWithoutReason:
  Enabled: true
RSpec/ReceiveMessages:
  Enabled: true
RSpec/RedundantAround:
  Enabled: true
RSpec/RedundantPredicateMatcher:
  Enabled: true
RSpec/RemoveConst:
  Enabled: true
RSpec/SkipBlockInsideExample:
  Enabled: true
RSpec/SortMetadata:
  Enabled: true
RSpec/SpecFilePathFormat:
  Enabled: true
RSpec/SpecFilePathSuffix:
  Enabled: true
RSpec/SubjectDeclaration:
  Enabled: true
RSpec/VerifiedDoubleReference:
  Enabled: true
RSpecRails/AvoidSetupHook:
  Enabled: true
RSpecRails/HaveHttpStatus:
  Enabled: true
RSpecRails/InferredSpecType:
  Enabled: true
RSpecRails/MinitestAssertions:
  Enabled: true
RSpecRails/NegationBeValid:
  Enabled: true
RSpecRails/TravelAround:
  Enabled: true
Style/SingleLineDoEndBlock:
  Enabled: true
Gemspec/AddRuntimeDependency:
  Enabled: true
Style/MapIntoArray:
  Enabled: true
Style/SendWithLiteralMethodName:
  Enabled: true
Style/SuperArguments:
  Enabled: true
Rails/WhereRange:
  Enabled: true
Lint/UselessNumericOperation:
  Enabled: true
Style/RedundantInterpolationUnfreeze:
  Enabled: true
Rails/EnumSyntax:
  Enabled: true

### Broken Cops that break code
Lint/ShadowedException: # Breaks "bundle exec rake rubocop" if enabled
  Enabled: false
Sequel/SaveChanges: # Breaks Code
  Enabled: false
Rails/DynamicFindBy: # Breaks Code
  Enabled: false
Rails/FindEach: # Breaks Code
  Enabled: false
Rails/RedundantActiveRecordAllMethod: # As we use Sequel this breaks code as it matches Sequel functions
  Enabled: false
Rails/CreateTableWithTimestamps: # Only works with ActiveRecord but we're using Sequel
  Enabled: false