Class: Rubocop::Cop::Cop
- Inherits:
-
Parser::AST::Processor
- Object
- Parser::AST::Processor
- Rubocop::Cop::Cop
show all
- Extended by:
- AST::Sexp
- Defined in:
- lib/rubocop/cop/cop.rb
Direct Known Subclasses
AccessControl, Alias, AlignParameters, AndOr, AsciiComments, AsciiIdentifiers, AvoidClassVars, AvoidFor, AvoidGlobalVars, AvoidPerlBackrefs, AvoidPerlisms, BlockComments, Blocks, CaseIndentation, ClassAndModuleCamelCase, ClassMethods, CollectionMethods, ColonMethodCall, ConstantName, DefWithParentheses, DefWithoutParentheses, EmptyLineBetweenDefs, EmptyLines, EmptyLiteral, Encoding, EndOfLine, EnsureReturn, Eval, FavorJoin, FavorPercentR, FavorSprintf, FavorUnlessOverNegatedIf, FavorUntilOverNegatedWhile, HandleExceptions, HashSyntax, IfUnlessModifier, IfWithSemicolon, Lambda, LeadingCommentSpace, LineContinuation, LineLength, Loop, MethodAndVariableSnakeCase, MethodLength, MultilineIfThen, MultilineTernaryOperator, NestedTernaryOperator, Not, NumericLiterals, OneLineConditional, OpMethod, ParameterLists, ParenthesesAroundCondition, PercentR, Proc, ReduceArguments, RescueException, RescueModifier, Semicolon, SingleLineMethods, SpaceAfterColon, SpaceAfterComma, SpaceAfterControlKeyword, SpaceAfterSemicolon, SpaceAroundBraces, SpaceAroundEqualsInParameterDefault, SpaceAroundOperators, SpaceInsideBrackets, SpaceInsideHashLiteralBraces, SpaceInsideParens, StringLiterals, SymbolArray, SymbolName, Syntax, Tab, TrailingWhitespace, TrivialAccessors, UnlessElse, VariableInterpolation, WhenThen, WhileUntilModifier, WordArray
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Cop
Returns a new instance of Cop.
40
41
42
43
|
# File 'lib/rubocop/cop/cop.rb', line 40
def initialize
@offences = []
@debug = false
end
|
Class Attribute Details
.all ⇒ Object
Returns the value of attribute all.
28
29
30
|
# File 'lib/rubocop/cop/cop.rb', line 28
def all
@all
end
|
.config ⇒ Object
Returns the value of attribute config.
29
30
31
|
# File 'lib/rubocop/cop/cop.rb', line 29
def config
@config
end
|
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
21
22
23
|
# File 'lib/rubocop/cop/cop.rb', line 21
def debug
@debug
end
|
#disabled_lines=(value) ⇒ Object
Sets the attribute disabled_lines
22
23
24
|
# File 'lib/rubocop/cop/cop.rb', line 22
def disabled_lines=(value)
@disabled_lines = value
end
|
#offences ⇒ Object
Returns the value of attribute offences.
20
21
22
|
# File 'lib/rubocop/cop/cop.rb', line 20
def offences
@offences
end
|
Class Method Details
.cop_name ⇒ Object
36
37
38
|
# File 'lib/rubocop/cop/cop.rb', line 36
def self.cop_name
name.to_s.split('::').last
end
|
.inherited(subclass) ⇒ Object
32
33
34
|
# File 'lib/rubocop/cop/cop.rb', line 32
def self.inherited(subclass)
all << subclass
end
|
Instance Method Details
#add_offence(severity, line_number, message) ⇒ Object
60
61
62
63
64
65
|
# File 'lib/rubocop/cop/cop.rb', line 60
def add_offence(severity, line_number, message)
unless @disabled_lines && @disabled_lines.include?(line_number)
message = debug ? "#{name}: #{message}" : message
@offences << Offence.new(severity, line_number, message)
end
end
|
#has_report? ⇒ Boolean
45
46
47
|
# File 'lib/rubocop/cop/cop.rb', line 45
def has_report?
!@offences.empty?
end
|
#ignore_node(node) ⇒ Object
57
58
|
# File 'lib/rubocop/cop/cop.rb', line 57
def ignore_node(node)
end
|
#inspect(source, tokens, ast, comments) ⇒ Object
49
50
51
52
|
# File 'lib/rubocop/cop/cop.rb', line 49
def inspect(source, tokens, ast, )
process(ast)
.each { |c| (c) }
end
|
#name ⇒ Object
67
68
69
|
# File 'lib/rubocop/cop/cop.rb', line 67
def name
self.class.cop_name
end
|
54
55
|
# File 'lib/rubocop/cop/cop.rb', line 54
def ()
end
|