heronshoes/red_amber

View on GitHub
.rubocop.yml

Summary

Maintainability
Test Coverage
# We will use cops to detect bugs in an early stage
# Feel free to use .rubocop_todo.yml by --auto-gen-config
inherit_from: .rubocop_todo.yml

require:
  - rubocop-performance
  - rubocop-rubycw
  - rubocop-rake

AllCops:
  # drop support for 2.7 (since 0.3.0)
  TargetRubyVersion: 3.0
  # accept new cops if any
  NewCops: enable

# ===
# Globally I change these 3 cops from default

# alias is hard to see separately 
Style/Alias:
  EnforcedStyle: prefer_alias_method

# For consistency and portability
Style/TrailingCommaInArrayLiteral:
  EnforcedStyleForMultiline: comma
Style/TrailingCommaInHashLiteral:
  EnforcedStyleForMultiline: comma
# Should not set for Style/TrailingCommaInArguments

# ===

# To let you know the possibility of refactoring ===

# Max: 120
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
  Max: 90
  Exclude:
    - 'test/**/*'

# EnforcedStyle: aligned
Layout/MultilineMethodCallIndentation:
  EnforcedStyle: indented_relative_to_receiver

# Disabled to define Vector operators
# Offense count: 38
Lint/BinaryOperatorWithIdenticalOperands:
  Exclude:
    - 'test/test_vector_binary_element_wise.rb'

Lint/Debugger:
  Exclude:
    - 'bin/example'

# Need for test with empty block
# Offense count: 1
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
  Exclude:
    - 'test/test_group.rb'

# avoid unused variable asignment
# Offense count: 6
Lint/UselessAssignment:
  Exclude:
    - 'test/**/*'

# <= 17 satisfactory
# 18..30 unsatisfactory
# > 30 dangerous
# Offense count: 28
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
  Max: 30
  CountRepeatedAttributes: false
  AllowedMethods: [
    'join_merge_keys', # 54.18
    'join', # 53.1
    'dataframe_info', # 46.5
    'format_table', # 84.62
    'to_long', # 33.66
    'to_wide', #38.22
    'slice_by', # 38.29
    'remove', # 44.42
    'drop', # 31.42
    '[]', # 33.76
    'split', # 37.35
    'aggregate', # 38.13
    'filters', # 33.91
    'merge_keys', # 32.17
    'rename_keys', # 31.64
  ]

# Max: 25
# Offense count: 57
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
# AllowedMethods: refine
Metrics/BlockLength:
  Max: 25
  Exclude:
    - 'test/**/*'
    - 'lib/red_amber/helper.rb' # 32

# It's ok if class is big
# Max: 100
# Offense count: 15
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
  Exclude:
    - 'test/**/*'
    - 'lib/red_amber/data_frame.rb' # 162
    - 'lib/red_amber/group.rb' # 105
    - 'lib/red_amber/subframes.rb' # 110
    - 'lib/red_amber/vector.rb' # 152
    - 'lib/red_amber/vector_binary_element_wise.rb' # 109

# Only for monitoring. I will measure by PerceivedComplexity.
# Max: 7
# Offense count: 16
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/CyclomaticComplexity:
  Max: 12
  AllowedMethods: [
    'split', # 33
    'format_table', # 21
    'normalize_element', # 17
    'slice_by', # 16
    'assign_update', # 14
    'join', # 14
    'parse_range', # 14
    'remove', # 14
    '[]', # 13
    'drop', # 13
    'aggregate', # 13
  ]

# Max: 10
# Offense count: 34
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/MethodLength:
  Max: 30
  AllowedMethods: [
    'join', # 47
    'join_merge_keys', # 41
    'format_table', # 53
    'slice_by', # 38
    'assign_update', # 35
    'summarize', # 35
    'dataframe_info', # 33
    'drop', # 32
    'aggregate', # 31
  ]

# Max: 100
# Offense count: 5
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
  Max: 100
  Exclude:
    - 'lib/red_amber/data_frame_combinable.rb' # Max: 149
    - 'lib/red_amber/data_frame_displayable.rb' # Max: 226
    - 'lib/red_amber/data_frame_selectable.rb' # Max: 175
    - 'lib/red_amber/data_frame_variable_operation.rb' # Max: 171
    - 'lib/red_amber/vector_functions.rb' # Max: 165
    - 'lib/red_amber/vector_selectable.rb' # Max: 104
    - 'lib/red_amber/vector_updatable.rb' # Max: 103

# Max: 5
# Offense count: 1
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
  Exclude:
    - 'lib/red_amber/data_frame_combinable.rb' # Max: 6, at 'join'

# Max: 8
# Offense count: 15
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/PerceivedComplexity:
  Max: 10
  AllowedMethods: [
    'format_table', # 22
    'slice_by', # 20
    'normalize_element', # 17
    'assign_update', # 15
    'parse_range', # 15
    'join', # 14
    'remove', # 14
    'split', # 14
    'dataframe_info', # 13
    'replace', # 13
    'drop', # 12
    'initialize', # 12
    'aggregate', # 12
    '[]', # 11
    'filters', # 11
    'html_table', # 11
    'slice', # 11
    'pick', # 11
  ]

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
  Exclude:
    - 'lib/red-amber.rb'

# Necessary to define is_na, is_in, etc.
# Offense count: 3
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# ForbiddenPrefixes: is_, has_, have_
# AllowedMethods: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
  Exclude:
    - 'lib/red_amber/vector.rb'
    - 'lib/red_amber/vector_functions.rb'
    - 'lib/red_amber/vector_selectable.rb'

# avoid unused variable asignment
Rubycw/Rubycw:
  Exclude:
    - 'test/**/*'
    - 'bin/example'

# Offense count: 16
# This cop supports safe autocorrection (--autocorrect).
Style/OperatorMethodCall:
  Exclude:
    - 'test/test_vector_binary_element_wise.rb'

# Necessary to test when range.end == -1
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/SlicingWithRange:
  Exclude:
    - 'test/test_data_frame_selectable.rb'

Style/MixinUsage:
  Exclude:
    - 'bin/example'

# Necessary to Vector < 0 element-wise comparison
# Offense count: 5
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns, IgnoredMethods.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
  Exclude:
    - 'lib/red_amber/data_frame_selectable.rb'
    - 'lib/red_amber/vector_selectable.rb'