inherit_from: .rubocop_todo.yml require: - rubocop-performance - rubocop-rspec AllCops: TargetRubyVersion: 2.5 # Lowest version supported as of Rubocop 0.13.0 Include: - 'lib/**/*.rb' - 'test/**/*.rb' - 'spec/**/*.rb' - 'Gemfile' - 'Rakefile' Exclude: - 'Appraisals' - '*.gemspec' - 'lib/ddtrace/**/vendor/**/*.rb' - 'integration/apps/*/bin/*' - 'integration/apps/*/Gemfile' - 'lib/ddtrace/profiling/pprof/pprof_pb.rb' NewCops: disable # Don't allow new cops to be enabled implicitly. # 80 characters is a nice goal, but not worth currently changing in existing # code for the sake of changing it to conform to a length set in 1928 (IBM). Layout/LineLength: Max: 124 # These exceptions are good goals to attain, and probably will over time, # so periodic disabling and re-running to inspect values is suggested. Metrics/AbcSize: Max: 50 # TODO: As refactors continue, this should drop. However, the goal of # 10 lines in a method may be a little lofty. Metrics/MethodLength: Max: 36 Performance/Casecmp: Enabled: false # TODO: this is not compliant with the Ruby community style guide. We # should enable again this rule but it will change the public API because # we're using set_ methods. We should work on that because also Rails # honors this rule. Naming/AccessorMethodName: Enabled: false Style/RescueModifier: Enabled: false Style/NumericLiterals: Enabled: false Metrics/ClassLength: Max: 140 Metrics/BlockLength: Max: 42 Exclude: - test/**/* - spec/**/* Metrics/ParameterLists: Enabled: false Metrics/CyclomaticComplexity: Max: 15 Metrics/PerceivedComplexity: Max: 15 Lint/UnusedMethodArgument: Enabled: false Style/RescueStandardError: Enabled: false # alias and alias_method are not equivalent Style/Alias: Enabled: false # Disabling advices that would lead to incompatible Ruby 1.9 code Style/SymbolArray: Enabled: false # Simple conditionals are perfectly fine, and more readable for multiline # expressions. Style/GuardClause: Enabled: false # Case equality is not intrinsically problematic. Style/CaseEquality: Enabled: false # New cops since Rubocop 1.0. # We have to explicitly opt-in for new cops to apply # before the next major release. Gemspec/DateAssignment: # (new in 1.10) Enabled: true Layout/SpaceBeforeBrackets: # (new in 1.7) Enabled: true Lint/AmbiguousAssignment: # (new in 1.7) Enabled: true Lint/DeprecatedConstants: # (new in 1.8) Enabled: true Lint/DuplicateBranch: # (new in 1.3) Enabled: true Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1) Enabled: true Lint/EmptyClass: # (new in 1.3) Enabled: true Lint/LambdaWithoutLiteralBlock: # (new in 1.8) Enabled: true Lint/NoReturnInBeginEndBlocks: # (new in 1.2) Enabled: true Lint/NumberedParameterAssignment: # (new in 1.9) Enabled: true Lint/OrAssignmentToConstant: # (new in 1.9) Enabled: true Lint/RedundantDirGlobSort: # (new in 1.8) Enabled: true Lint/SymbolConversion: # (new in 1.9) Enabled: true Lint/ToEnumArguments: # (new in 1.1) Enabled: true Lint/TripleQuotes: # (new in 1.9) Enabled: true Lint/UnexpectedBlockArity: # (new in 1.5) Enabled: true Lint/UnmodifiedReduceAccumulator: # (new in 1.1) Enabled: true Style/ArgumentsForwarding: # (new in 1.1) Enabled: true Style/DocumentDynamicEvalDefinition: # (new in 1.1) Enabled: true Style/EndlessMethod: # (new in 1.8) Enabled: true Style/HashExcept: # (new in 1.7) Enabled: true Style/IfWithBooleanLiteralBranches: # (new in 1.9) Enabled: true Style/NilLambda: # (new in 1.3) Enabled: true Style/RedundantArgument: # (new in 1.4) Enabled: true Style/SwapValues: # (new in 1.1) Enabled: true Performance/AncestorsInclude: # (new in 1.7) Enabled: true Performance/BigDecimalWithNumericArgument: # (new in 1.7) Enabled: true Performance/BlockGivenWithExplicitBlock: # (new in 1.9) Enabled: true Performance/CollectionLiteralInLoop: # (new in 1.8) Enabled: true Performance/ConstantRegexp: # (new in 1.9) Enabled: true Performance/MethodObjectAsBlock: # (new in 1.9) 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: true Performance/Sum: # (new in 1.8) Enabled: true # Requires Ruby 2.2 Style/HashSyntax: Enabled: false # Requires Ruby 2.3 Style/SafeNavigation: Enabled: false # Requires Ruby 2.3 Performance/UnfreezeString: Enabled: false # Requires Ruby 2.4 Style/HashTransformValues: Enabled: false # Requires Ruby 2.4 Style/CollectionCompact: Enabled: false # Requires Ruby 2.4 Performance/RegexpMatch: Enabled: false # Requires Ruby 2.5 Style/RedundantBegin: Enabled: false # Requires Ruby 2.5 Style/HashTransformKeys: Enabled: false # Enforces negative/positive branching order, # which can hurt readability. Style/NegatedIfElseCondition: Enabled: false # Converts `to change{foo.bar}` to `to change(foo, :bar)`. # It doesn't seem to make it more readable, and doesn't work # when `foo` has to be re-evaluated. RSpec/ExpectChange: Enabled: false # Readability is not meaningfully affected by enforcing # `not_to` vs `to_not`. RSpec/NotToNot: Enabled: false # Enforces `subject` above all else, even `include_context` # declarations. RSpec/LeadingSubject: Enabled: false # Enforces usage of `expect(subject)` instead of `is_expected`. RSpec/ImplicitSubject: Enabled: false # Enforces empty line after hook declaration. RSpec/EmptyLineAfterHook: Enabled: false # Enforces empty line after subject declaration. RSpec/EmptyLineAfterSubject: Enabled: false # Enforces empty line after last let declaration. RSpec/EmptyLineAfterFinalLet: Enabled: false # TODO: Disabling until we categorize which file are safe to do so. Style/FrozenStringLiteralComment: Enabled: false # Replaces `x == 0` with `x.zero?` and similar. # These methods are ~2x slower than the simple math comparison. Style/NumericPredicate: Enabled: false # Allow for empty blocks (without a comment) in tests. Lint/EmptyBlock: Exclude: - 'test/**/*.rb' - 'spec/**/*.rb' # Enforces that context description must start with 'when', 'with', or 'without'. RSpec/ContextWording: Enabled: false # Checks for multiple top-level example groups. # Multiple descriptions for the same class or module should either # be nested or separated into different test files. RSpec/MultipleDescribes: Enabled: false # Enforces that examples should only have a limited amount of assertions. RSpec/MultipleExpectations: Enabled: false # Enforces minimum character length for parameters. Naming/MethodParameterName: Enabled: false # Enforces no instance variable in specs. RSpec/InstanceVariable: Enabled: false # Enforces a maximum nested example group level. RSpec/NestedGroups: Enabled: false # Enforces `receive` vs `have_received` expectation pattern. RSpec/MessageSpies: Enabled: false # Enforces example line count limit. RSpec/ExampleLength: Enabled: false # Enforces maximum let and subject calls. RSpec/MultipleMemoizedHelpers: Enabled: false # Enforces `allow` over `expect` when configuring a response. RSpec/StubbedMock: Enabled: false # Enforces no use of `expect` in `before` hooks. RSpec/ExpectInHook: Enabled: false # Enforces no stubbing using `allow_any_instance_of`. RSpec/AnyInstance: Enabled: false # Enforces strict matching of example class with spec file name. # This does not work for our current namespacing as our gem is called # `ddtrace` while our namespace is `::Datadog`. # It would have to either be `ddtrace` + `::DDTrace` or # `datadog` + `::Datadog`. RSpec/FilePath: Enabled: false # Enforces no stubbing of methods of the object under test. RSpec/SubjectStub: Enabled: false # Enforces that the first argument to describe should # be the class or module being tested. RSpec/DescribeClass: Enabled: false # Enforces to no use let! to setup objects not referenced in tests. # Fails to account for shared examples across files. RSpec/LetSetup: Enabled: false # Identifies where `fetch(key) { value }` can be replaced by `fetch(key, value)`. # Can't differentiate between `Hash#fetch` and `RailsCache#fetch`, # passing in wrong parameters to these methods. Style/RedundantFetchBlock: Enabled: false # Warns about usage of `before(:all)` RSpec/BeforeAfterAll: Enabled: false # Enforces snake case file names. Naming/FileName: Exclude: - 'integration/**/Gemfile' - 'integration/**/Rakefile' # Enforces boolean parameters with default to be keyword arguments. Style/OptionalBooleanParameter: Enabled: false