Skip to content

Commit

Permalink
make the code rubocop safe
Browse files Browse the repository at this point in the history
  • Loading branch information
gfx committed Jun 10, 2017
1 parent 4a9e3c9 commit 680e230
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Lint/EmptyWhen:
Lint/UnneededSplatExpansion:
Enabled: false

Lint/IneffectiveAccessModifier:
Enabled: false

# TODO: enable it in a future because `ruby -w` warns it
Lint/AmbiguousRegexpLiteral:
Enabled: false
Expand Down
4 changes: 2 additions & 2 deletions lib/rouge/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def run
formatter.format(lexer.lex(input), &method(:print))
end

private
private_class_method
def self.parse_cgi(str)
pairs = CGI.parse(str).map { |k, v| [k.to_sym, v.first] }
Hash[pairs]
Expand Down Expand Up @@ -374,7 +374,7 @@ def run
end
end

private
private_class_method
def self.normalize_syntax(argv)
out = []
argv.each do |arg|
Expand Down
2 changes: 1 addition & 1 deletion lib/rouge/formatters/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def safe_span(tok, safe_val)
end
end

private

TABLE_FOR_ESCAPE_HTML = {
'&' => '&',
'<' => '&lt;',
Expand Down
6 changes: 3 additions & 3 deletions lib/rouge/lexers/liquid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Liquid < RegexLexer
state :filters do
mixin :whitespace

rule (/\}\}/) { token Punctuation; reset_stack }
rule(/\}\}/) { token Punctuation; reset_stack }

rule /([^\s\|:]+)(:?)(\s*)/ do
groups Name::Function, Punctuation, Text::Whitespace
Expand Down Expand Up @@ -156,11 +156,11 @@ class Liquid < RegexLexer
end

state :end_of_tag do
rule (/\}\}/) { token Punctuation; reset_stack }
rule(/\}\}/) { token Punctuation; reset_stack }
end

state :end_of_block do
rule (/%\}/) { token Punctuation; reset_stack }
rule(/%\}/) { token Punctuation; reset_stack }
end

# states for unknown markup
Expand Down
2 changes: 1 addition & 1 deletion lib/rouge/lexers/nasm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def self.builtins

state :root do
mixin :expr_whitespace
rule (//) { push :statement }
rule(//) { push :statement }
rule /^%[a-zA-Z0-9]+/, Comment::Preproc, :statement

rule(
Expand Down
6 changes: 3 additions & 3 deletions lib/rouge/lexers/protobuf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ class Protobuf < RegexLexer

state :package do
rule /[a-zA-Z_]\w*/, Name::Namespace, :pop!
rule (//) { pop! }
rule(//) { pop! }
end

state :message do
rule /[a-zA-Z_]\w*/, Name::Class, :pop!
rule (//) { pop! }
rule(//) { pop! }
end

state :type do
rule /[a-zA-Z_]\w*/, Name, :pop!
rule (//) { pop! }
rule(//) { pop! }
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/rouge/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ def initialize(parent=nil)
end

def [](k)
_sup = super
return _sup if own_keys.include?(k)
value = super
return value if own_keys.include?(k)

_sup || parent[k]
value || parent[k]
end

def parent
Expand Down

0 comments on commit 680e230

Please sign in to comment.