class RuboCop::SketchUp::Cop

@abstract parent class to SketchUp cops

The criteria for whether rubocop-sketchup analyzes a certain ruby file is configured via `AllCops/SketchUp`. For example, if you want to customize your project to scan all files within a `test/` directory then you could add this to your configuration:

@example configuring analyzed paths

AllCops:
  SketchUp:
    SketchupDeprecations:
      Exclude:
      - '_test.rb$'
      - '(?:^|/)test/'

Constants

SKETCHUP_DEPARTMENT_SEVERITY

Public Class Methods

inherited(subclass) click to toggle source

Invoke the original inherited hook so our cops are recognized

# File lib/rubocop/sketchup/cop.rb, line 54
def self.inherited(subclass) # rubocop:disable Lint/MissingSuper
  RuboCop::Cop::Cop.inherited(subclass)
end

Public Instance Methods

relevant_file?(file) click to toggle source
Calls superclass method
# File lib/rubocop/sketchup/cop.rb, line 58
def relevant_file?(file)
  relevant_rubocop_sketchup_file?(file) && super
end

Private Instance Methods

default_severity() click to toggle source
Calls superclass method
# File lib/rubocop/sketchup/cop.rb, line 64
def default_severity
  sketchup_severity || super
end
department_name() click to toggle source
# File lib/rubocop/sketchup/cop.rb, line 72
def department_name
  self.class.department.to_s
end
matches_file?(file, patterns) click to toggle source
# File lib/rubocop/sketchup/cop.rb, line 85
def matches_file?(file, patterns)
  path = nil
  patterns.any? do |pattern|
    # Try to match the absolute path, as Exclude properties are absolute.
    next true if match_path?(pattern, file)

    # Try with relative path.
    path ||= config.path_relative_to_config(file)
    match_path?(pattern, path)
  end
end
relevant_rubocop_sketchup_file?(file) click to toggle source
# File lib/rubocop/sketchup/cop.rb, line 76
def relevant_rubocop_sketchup_file?(file)
  !sketchup_excluded?(file)
end
sketchup_department_exclude_pattern() click to toggle source
# File lib/rubocop/sketchup/cop.rb, line 97
def sketchup_department_exclude_pattern
  sketchup_cops_config
    .fetch(department_name, {})
    .fetch('Exclude', [])
end
sketchup_exclude_pattern() click to toggle source
# File lib/rubocop/sketchup/cop.rb, line 103
def sketchup_exclude_pattern
  sketchup_cops_config
    .fetch('Exclude', [])
end
sketchup_excluded?(file) click to toggle source
# File lib/rubocop/sketchup/cop.rb, line 80
def sketchup_excluded?(file)
  matches_file?(file, sketchup_exclude_pattern) ||
    matches_file?(file, sketchup_department_exclude_pattern)
end
sketchup_severity() click to toggle source
# File lib/rubocop/sketchup/cop.rb, line 68
def sketchup_severity
  SKETCHUP_DEPARTMENT_SEVERITY[self.class.department]
end