Skip to content
Open
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.3
DisplayStyleGuide: true
Exclude:
- 'test/scanners/**/*'
- 'bench/example.ruby'
Expand Down
36 changes: 1 addition & 35 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,7 @@ Layout/SpaceAfterComma:
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Layout/SpaceAroundOperators:
Exclude:
- 'ideosyncratic-ruby.rb'
- 'lib/coderay/scanners/c.rb'
- 'lib/coderay/scanners/cpp.rb'
- 'lib/coderay/scanners/diff.rb'
- 'lib/coderay/scanners/groovy.rb'
- 'lib/coderay/scanners/java.rb'
- 'lib/coderay/scanners/java_script.rb'
- 'lib/coderay/scanners/python.rb'
- 'lib/coderay/scanners/ruby/patterns.rb'
- 'rake_tasks/code_statistics.rb'
- 'test/unit/json_encoder.rb'
AllowForAlignment: true

# Offense count: 2
# Cop supports --auto-correct.
Expand Down Expand Up @@ -541,29 +530,6 @@ Naming/VariableNumber:
Exclude:
- 'test/unit/tokens.rb'

# Offense count: 1
Performance/Caller:
Exclude:
- 'lib/coderay/scanners/scanner.rb'

# Offense count: 1
# Cop supports --auto-correct.
Performance/Casecmp:
Exclude:
- 'rake_tasks/generator.rake'

# Offense count: 1
# Cop supports --auto-correct.
Performance/StringReplacement:
Exclude:
- 'lib/coderay/encoders/html.rb'

# Offense count: 3
Performance/UnfreezeString:
Exclude:
- 'lib/coderay/encoders/encoder.rb'
- 'lib/coderay/encoders/html.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect.
Expand Down
12 changes: 5 additions & 7 deletions lib/coderay/scanners/java_script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ class JavaScript < Scanner
add(KEYWORDS, :keyword) # :nodoc:

ESCAPE = / [bfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc:
UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc:
REGEXP_ESCAPE = / [bBdDsSwW] /x # :nodoc:
STRING_CONTENT_PATTERN = {
UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc:
REGEXP_ESCAPE = / [bBdDsSwW] /x # :nodoc:
STRING_CONTENT_PATTERN = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Operator = should be surrounded by a single space. (https://rubystyle.guide#spaces-operators)

"'" => /[^\\']+/,
'"' => /[^\\"]+/,
'/' => /[^\\\/]+/,
} # :nodoc:
'/' => %r{ (?: [^\\/\[]+ | \[ ([^\]\\]+ | \\.)* \]? )+ }mx,
}.freeze # :nodoc:
KEY_CHECK_PATTERN = {
"'" => / (?> [^\\']* (?: \\. [^\\']* )* ) ' \s* : /mx,
'"' => / (?> [^\\"]* (?: \\. [^\\"]* )* ) " \s* : /mx,
Expand Down Expand Up @@ -219,8 +219,6 @@ def scan_tokens encoder, options
encoder
end

protected

def reset_instance
super
@xml_scanner.reset if defined? @xml_scanner
Expand Down