Skip to content

Commit

Permalink
Fix private class unused variable warnings (#2031)
Browse files Browse the repository at this point in the history
* Fix warnings about private_class_method usage

* Unused variable warnings

Most of these should just be removed instead of underscored... but I
want eyeballs on this first. Some aren't being used the way they think
they're being used.

* Remove unused variable warnings in GDScript

* Remove unused variables

* Remove parentheses after method name warnings

* Remove regexp ambiguity warnings

---------

Co-authored-by: Ryan Davis <[email protected]>
  • Loading branch information
tancnle and zenspider authored Mar 18, 2024
1 parent 4a52324 commit 2fa465a
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 21 deletions.
6 changes: 2 additions & 4 deletions lib/rouge/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ def run
formatter.format(lexer.lex(input), &method(:print))
end

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


private_class_method
def self.normalize_syntax(argv)
private_class_method def self.normalize_syntax(argv)
out = []
argv.each do |arg|
case arg
Expand Down
8 changes: 4 additions & 4 deletions lib/rouge/lexers/gdscript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GDScript < RegexLexer
mimetypes 'text/x-gdscript', 'application/x-gdscript'

def self.keywords
@keywords = %w(
@keywords ||= %w(
and in not or as breakpoint class class_name extends is func setget
signal tool const enum export onready static var break continue
if elif else for pass return match while remote master puppet
Expand All @@ -22,13 +22,13 @@ def self.keywords

# Reserved for future implementation
def self.keywords_reserved
@keywords_reserved = %w(
@keywords_reserved ||= %w(
do switch case
).join('|')
end

def self.builtins
builtins = %w(
@builtins ||= %w(
Color8 ColorN abs acos asin assert atan atan2 bytes2var ceil char
clamp convert cos cosh db2linear decimals dectime deg2rad dict2inst
ease exp floor fmod fposmod funcref hash inst2dict instance_from_id
Expand All @@ -41,7 +41,7 @@ def self.builtins
end

def self.builtins_type
@builtins_type = %w(
@builtins_type ||= %w(
bool int float String Vector2 Rect2 Transform2D Vector3 AABB
Plane Quat Basis Transform Color RID Object NodePath Dictionary
Array PoolByteArray PoolIntArray PoolRealArray PoolStringArray
Expand Down
1 change: 0 additions & 1 deletion lib/rouge/lexers/meson.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def self.builtin_functions
end

identifier = /[[:alpha:]_][[:alnum:]_]*/
dotted_identifier = /[[:alpha:]_.][[:alnum:]_.]*/

def current_string
@current_string ||= StringRegister.new
Expand Down
2 changes: 0 additions & 2 deletions lib/rouge/lexers/objective_c/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
module Rouge
module Lexers
module ObjectiveCCommon
id = /[a-z$_][a-z0-9$_]*/i

def at_keywords
@at_keywords ||= %w(
selector private protected public encode synchronized try
Expand Down
2 changes: 0 additions & 2 deletions lib/rouge/lexers/openedge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class OpenEdge < RegexLexer
title 'OpenEdge ABL'
desc 'The OpenEdge ABL programming language'

# optional comment or whitespace
ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
id = /[a-zA-Z_&{}!][a-zA-Z0-9_\-&!}]*/

def self.keywords
Expand Down
1 change: 0 additions & 1 deletion lib/rouge/lexers/syzlang.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def self.keywords_type

comment = /#.*$/
inline_spaces = /[ \t]+/
eol_spaces = /[\n\r]+/
spaces = /\s+/

state :inline_break do
Expand Down
2 changes: 0 additions & 2 deletions lib/rouge/lexers/ttcn3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ def self.types
)
end

# optional comment or whitespace
ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
id = /[a-zA-Z_]\w*/
digit = /\d_+\d|\d/
bin_digit = /[01]_+[01]|[01]/
Expand Down
2 changes: 1 addition & 1 deletion lib/rouge/tex_theme_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def token_name(tok)
end

def render_blank(tok, &b)
out = "\\expandafter\\def#{token_name(tok)}#1{#1}"
"\\expandafter\\def#{token_name(tok)}#1{#1}"
end

def render_style(tok, style, &b)
Expand Down
2 changes: 0 additions & 2 deletions spec/guesser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
it 'sequentially filters' do
custom = Class.new(Rouge::Guesser) {
define_method(:filter) { |lexers|
passed_lexers = lexers

[Rouge::Lexers::Javascript, Rouge::Lexers::Prolog]
}
}.new
Expand Down
2 changes: 1 addition & 1 deletion tasks/builtins/lasso.rake
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module Rouge
keywords
end

def render_output (keywords, &b)
def render_output(keywords, &b)
return enum_for(:render_output, keywords).to_a.join("\n") unless b

yield "# -*- coding: utf-8 -*- #"
Expand Down
2 changes: 1 addition & 1 deletion tasks/builtins/sqf.rake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Rouge
module Builtins
class SQF
def extract_keywords(input)
input.scrub.scan /(?<=\(").+?(?=")/
input.scrub.scan(/(?<=\(").+?(?=")/)
end

def render_output(keywords, &b)
Expand Down

0 comments on commit 2fa465a

Please sign in to comment.