mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
Ruby: Inline expectation should have space after $
This was a regex-find-replace from `# \$(?! )` (using a negative lookahead) to `# $ `.
This commit is contained in:
@@ -5,8 +5,8 @@ require 'cgi'
|
||||
class UnicodeNormalizationOKController < ActionController::Base
|
||||
def unicodeNormalize
|
||||
unicode_input = params[:unicode_input]
|
||||
normalized_nfkc = unicode_input.unicode_normalize(:nfkc) # $MISSING:result=OK
|
||||
normalized_nfc = unicode_input.unicode_normalize(:nfc) # $MISSING:result=OK
|
||||
normalized_nfkc = unicode_input.unicode_normalize(:nfkc) # $ MISSING:result=OK
|
||||
normalized_nfc = unicode_input.unicode_normalize(:nfc) # $ MISSING:result=OK
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,8 +14,8 @@ class UnicodeNormalizationStrManipulationController < ActionController::Base
|
||||
def unicodeNormalize
|
||||
unicode_input = params[:unicode_input]
|
||||
unicode_input_manip = unicode_input.sub(/[aeiou]/, "*")
|
||||
normalized_nfkc = unicode_input_manip.unicode_normalize(:nfkc) # $result=BAD
|
||||
normalized_nfc = unicode_input_manip.unicode_normalize(:nfc) # $result=BAD
|
||||
normalized_nfkc = unicode_input_manip.unicode_normalize(:nfkc) # $ result=BAD
|
||||
normalized_nfc = unicode_input_manip.unicode_normalize(:nfc) # $ result=BAD
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,8 +23,8 @@ class UnicodeNormalizationHtMLEscapeController < ActionController::Base
|
||||
def unicodeNormalize
|
||||
unicode_input = params[:unicode_input]
|
||||
unicode_html_safe = html_escape(unicode_input)
|
||||
normalized_nfkc = unicode_html_safe.unicode_normalize(:nfkc) # $result=BAD
|
||||
normalized_nfc = unicode_html_safe.unicode_normalize(:nfc) # $result=BAD
|
||||
normalized_nfkc = unicode_html_safe.unicode_normalize(:nfkc) # $ result=BAD
|
||||
normalized_nfc = unicode_html_safe.unicode_normalize(:nfc) # $ result=BAD
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ class UnicodeNormalizationCGIHtMLEscapeController < ActionController::Base
|
||||
def unicodeNormalize
|
||||
unicode_input = params[:unicode_input]
|
||||
unicode_html_safe = CGI.escapeHTML(unicode_input).html_safe
|
||||
normalized_nfkc = unicode_html_safe.unicode_normalize(:nfkd) # $result=BAD
|
||||
normalized_nfc = unicode_html_safe.unicode_normalize(:nfd) # $result=BAD
|
||||
normalized_nfkc = unicode_html_safe.unicode_normalize(:nfkd) # $ result=BAD
|
||||
normalized_nfc = unicode_html_safe.unicode_normalize(:nfd) # $ result=BAD
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,7 +52,7 @@ def m7(arg)
|
||||
arg += 3
|
||||
end
|
||||
@m7
|
||||
end # $result=BAD
|
||||
end # $ result=BAD
|
||||
|
||||
# Bad: method has parameter but only one result is memoized.
|
||||
def m8(arg)
|
||||
@@ -60,23 +60,23 @@ def m8(arg)
|
||||
long_running_method(arg)
|
||||
end
|
||||
@m8
|
||||
end # $result=BAD
|
||||
end # $ result=BAD
|
||||
|
||||
# Bad: method has parameter but only one result is memoized.
|
||||
def m9(arg)
|
||||
@m9 ||= long_running_method(arg)
|
||||
end # $result=BAD
|
||||
end # $ result=BAD
|
||||
|
||||
# Bad: method has parameter but only one result is memoized.
|
||||
def m10(arg1, arg2)
|
||||
@m10 ||= long_running_method(arg1, arg2)
|
||||
end # $result=BAD
|
||||
end # $ result=BAD
|
||||
|
||||
# Bad: `arg2` not used in key.
|
||||
def m11(arg1, arg2)
|
||||
@m11 ||= {}
|
||||
@m11[arg1] ||= long_running_method(arg1, arg2)
|
||||
end # $result=BAD
|
||||
end # $ result=BAD
|
||||
|
||||
# Bad: `arg2` not used in key.
|
||||
def m12(arg1, arg2)
|
||||
@@ -84,7 +84,7 @@ def m12(arg1, arg2)
|
||||
h1[arg1] = result(arg1, arg2)
|
||||
end
|
||||
@m12[arg1]
|
||||
end # $result=BAD
|
||||
end # $ result=BAD
|
||||
|
||||
# Bad: arg not used in key.
|
||||
def m13(id:)
|
||||
@@ -94,11 +94,11 @@ def m13(id:)
|
||||
end
|
||||
end
|
||||
@m13
|
||||
end # $result=BAD
|
||||
end # $ result=BAD
|
||||
|
||||
# Good (FP): arg is used in key via string interpolation.
|
||||
def m14(arg)
|
||||
@m14 ||= {}
|
||||
key = "foo/#{arg}"
|
||||
@m14[key] ||= long_running_method(arg)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
source "https://rubygems.org" # GOOD
|
||||
source "http://rubygems.org" # $result=BAD
|
||||
source "ftp://rubygems.org" # $result=BAD
|
||||
source "http://rubygems.org" # $ result=BAD
|
||||
source "ftp://rubygems.org" # $ result=BAD
|
||||
source "ftps://rubygems.org" # GOOD
|
||||
source "unknown://rubygems.org" # GOOD
|
||||
|
||||
git_source(:a) { "https://github.com" } # GOOD
|
||||
git_source(:b) { "http://github.com" } # $result=BAD
|
||||
git_source(:c) { "ftp://github.com" } # $result=BAD
|
||||
git_source(:b) { "http://github.com" } # $ result=BAD
|
||||
git_source(:c) { "ftp://github.com" } # $ result=BAD
|
||||
git_source(:d) { "ftps://github.com" } # GOOD
|
||||
git_source(:e) { "unknown://github.com" } # GOOD
|
||||
|
||||
git_source(:f) { |name| "https://github.com/#{name}" } # GOOD
|
||||
git_source(:g) { |name| "http://github.com/#{name}" } # $result=BAD
|
||||
git_source(:h) { |name| "ftp://github.com/#{name}" } # $result=BAD
|
||||
git_source(:g) { |name| "http://github.com/#{name}" } # $ result=BAD
|
||||
git_source(:h) { |name| "ftp://github.com/#{name}" } # $ result=BAD
|
||||
git_source(:i) { |name| "ftps://github.com/#{name}" } # GOOD
|
||||
git_source(:j) { |name| "unknown://github.com/#{name}" } # GOOD
|
||||
|
||||
@@ -22,11 +22,11 @@ git_source(:k) do |name|
|
||||
end
|
||||
git_source(:l) do |name|
|
||||
foo
|
||||
"http://github.com/#{name}" # $result=BAD
|
||||
"http://github.com/#{name}" # $ result=BAD
|
||||
end
|
||||
git_source(:m) do |name|
|
||||
foo
|
||||
"ftp://github.com/#{name}" # $result=BAD
|
||||
"ftp://github.com/#{name}" # $ result=BAD
|
||||
end
|
||||
git_source(:n) do |name|
|
||||
foo
|
||||
@@ -38,19 +38,19 @@ git_source(:o) do |name|
|
||||
end
|
||||
|
||||
gem "jwt", "1.2.3", git: "https://github.com/jwt/ruby-jwt" # GOOD
|
||||
gem "jwt", "1.2.3", git: "http://github.com/jwt/ruby-jwt" # $result=BAD
|
||||
gem "jwt", "1.2.3", git: "ftp://github.com/jwt/ruby-jwt" # $result=BAD
|
||||
gem "jwt", "1.2.3", git: "http://github.com/jwt/ruby-jwt" # $ result=BAD
|
||||
gem "jwt", "1.2.3", git: "ftp://github.com/jwt/ruby-jwt" # $ result=BAD
|
||||
gem "jwt", "1.2.3", git: "ftps://github.com/jwt/ruby-jwt" # GOOD
|
||||
gem "jwt", "1.2.3", git: "unknown://github.com/jwt/ruby-jwt" # GOOD
|
||||
|
||||
gem "jwt", "1.2.3", :git => "https://github.com/jwt/ruby-jwt" # GOOD
|
||||
gem "jwt", "1.2.3", :git => "http://github.com/jwt/ruby-jwt" # $result=BAD
|
||||
gem "jwt", "1.2.3", :git => "ftp://github.com/jwt/ruby-jwt" # $result=BAD
|
||||
gem "jwt", "1.2.3", :git => "http://github.com/jwt/ruby-jwt" # $ result=BAD
|
||||
gem "jwt", "1.2.3", :git => "ftp://github.com/jwt/ruby-jwt" # $ result=BAD
|
||||
gem "jwt", "1.2.3", :git => "ftps://github.com/jwt/ruby-jwt" # GOOD
|
||||
gem "jwt", "1.2.3", :git => "unknown://github.com/jwt/ruby-jwt" # GOOD
|
||||
|
||||
gem "jwt", "1.2.3", source: "https://rubygems.org" # GOOD
|
||||
gem "jwt", "1.2.3", source: "http://rubygems.org" # $result=BAD
|
||||
gem "jwt", "1.2.3", source: "ftp://rubygems.org" # $result=BAD
|
||||
gem "jwt", "1.2.3", source: "http://rubygems.org" # $ result=BAD
|
||||
gem "jwt", "1.2.3", source: "ftp://rubygems.org" # $ result=BAD
|
||||
gem "jwt", "1.2.3", source: "ftps://rubygems.org" # GOOD
|
||||
gem "jwt", "1.2.3", source: "unknown://rubygems.org" # GOOD
|
||||
gem "jwt", "1.2.3", source: "unknown://rubygems.org" # GOOD
|
||||
|
||||
Reference in New Issue
Block a user