summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2019-11-24 15:23:28 +0100
committerKornelius Kalnbach <murphy@rubychan.de>2019-11-24 15:23:28 +0100
commit54268a946b9bfde526d6d8c28bdb4c8f956eee32 (patch)
tree25e133d24be196a048c1a3ab99651e226a87ad98
parente3228fa76dd8f26ea7e240c67dcd90cea9106d11 (diff)
parentb5b3430d4635682b767c44469e28a70fe234187e (diff)
downloadcoderay-fix-javascript-regexp.tar.gz
Merge branch 'master' into fix-javascript-regexpfix-javascript-regexp
-rw-r--r--.codeclimate.yml26
-rw-r--r--lib/coderay/scanners/c.rb2
-rw-r--r--lib/coderay/scanners/cpp.rb2
-rw-r--r--lib/coderay/scanners/diff.rb4
-rw-r--r--lib/coderay/scanners/groovy.rb4
-rw-r--r--lib/coderay/scanners/java.rb2
-rw-r--r--lib/coderay/scanners/python.rb2
-rw-r--r--lib/coderay/scanners/ruby/patterns.rb2
-rw-r--r--rake_tasks/code_statistics.rb2
-rw-r--r--test/unit/json_encoder.rb14
10 files changed, 43 insertions, 17 deletions
diff --git a/.codeclimate.yml b/.codeclimate.yml
new file mode 100644
index 0000000..c01311f
--- /dev/null
+++ b/.codeclimate.yml
@@ -0,0 +1,26 @@
+version: "2"
+checks:
+ argument-count:
+ enabled: false
+ complex-logic:
+ enabled: false
+ file-lines:
+ enabled: false
+ identical-code:
+ enabled: false
+ method-complexity:
+ enabled: false
+ method-count:
+ enabled: false
+ method-lines:
+ enabled: false
+ nested-control-flow:
+ enabled: false
+ return-statements:
+ enabled: false
+ similar-code:
+ enabled: false
+plugins:
+ rubocop:
+ enabled: true
+ channel: rubocop-0-76
diff --git a/lib/coderay/scanners/c.rb b/lib/coderay/scanners/c.rb
index 84b6e8e..fb2f30d 100644
--- a/lib/coderay/scanners/c.rb
+++ b/lib/coderay/scanners/c.rb
@@ -37,7 +37,7 @@ module Scanners
add(PREDEFINED_CONSTANTS, :predefined_constant) # :nodoc:
ESCAPE = / [rbfntv\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:
+ UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc:
protected
diff --git a/lib/coderay/scanners/cpp.rb b/lib/coderay/scanners/cpp.rb
index 40aeb42..cd4d094 100644
--- a/lib/coderay/scanners/cpp.rb
+++ b/lib/coderay/scanners/cpp.rb
@@ -49,7 +49,7 @@ module Scanners
add(PREDEFINED_CONSTANTS, :predefined_constant) # :nodoc:
ESCAPE = / [rbfntv\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:
+ UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc:
protected
diff --git a/lib/coderay/scanners/diff.rb b/lib/coderay/scanners/diff.rb
index 74a6c27..a2a6fcc 100644
--- a/lib/coderay/scanners/diff.rb
+++ b/lib/coderay/scanners/diff.rb
@@ -109,7 +109,7 @@ module Scanners
for deleted_line, inserted_line in deleted_lines.zip(inserted_lines)
pre, deleted_part, inserted_part, post = diff deleted_line, inserted_line
content_scanner_entry_state = content_scanner.state
- deleted_lines_tokenized << content_scanner.tokenize([pre, deleted_part, post], :tokens => Tokens.new)
+ deleted_lines_tokenized << content_scanner.tokenize([pre, deleted_part, post], :tokens => Tokens.new)
content_scanner.state = content_scanner_entry_state || :initial
inserted_lines_tokenized << content_scanner.tokenize([pre, inserted_part, post], :tokens => Tokens.new)
end
@@ -212,7 +212,7 @@ module Scanners
# does not precede the leftmost one from the left.
j = -1
j -= 1 while j >= j_min && a[j] == b[j]
- return a[0...i], a[i..j], b[i..j], (j < -1) ? a[j+1..-1] : ''
+ return a[0...i], a[i..j], b[i..j], (j < -1) ? a[j + 1..-1] : ''
end
end
diff --git a/lib/coderay/scanners/groovy.rb b/lib/coderay/scanners/groovy.rb
index c64454f..c52ce8d 100644
--- a/lib/coderay/scanners/groovy.rb
+++ b/lib/coderay/scanners/groovy.rb
@@ -22,8 +22,8 @@ module Scanners
add(GROOVY_MAGIC_VARIABLES, :local_variable) # :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} /x # :nodoc: no 4-byte unicode chars? U[a-fA-F0-9]{8}
- REGEXP_ESCAPE = / [bfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} | \d | [bBdDsSwW\/] /x # :nodoc:
+ UNICODE_ESCAPE = / u[a-fA-F0-9]{4} /x # :nodoc: no 4-byte unicode chars? U[a-fA-F0-9]{8}
+ REGEXP_ESCAPE = / [bfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} | \d | [bBdDsSwW\/] /x # :nodoc:
# TODO: interpretation inside ', ", /
STRING_CONTENT_PATTERN = {
diff --git a/lib/coderay/scanners/java.rb b/lib/coderay/scanners/java.rb
index a490ec6..7dd1919 100644
--- a/lib/coderay/scanners/java.rb
+++ b/lib/coderay/scanners/java.rb
@@ -38,7 +38,7 @@ module Scanners
add(DIRECTIVES, :directive) # :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:
+ UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc:
STRING_CONTENT_PATTERN = {
"'" => /[^\\']+/,
'"' => /[^\\"]+/,
diff --git a/lib/coderay/scanners/python.rb b/lib/coderay/scanners/python.rb
index 09c8b6e..5da553a 100644
--- a/lib/coderay/scanners/python.rb
+++ b/lib/coderay/scanners/python.rb
@@ -63,7 +63,7 @@ module Scanners
NAME = / [[:alpha:]_] \w* /x # :nodoc:
ESCAPE = / [abfnrtv\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} | N\{[-\w ]+\} /x # :nodoc:
+ UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} | N\{[-\w ]+\} /x # :nodoc:
OPERATOR = /
\.\.\. | # ellipsis
diff --git a/lib/coderay/scanners/ruby/patterns.rb b/lib/coderay/scanners/ruby/patterns.rb
index e5a156d..cd942d0 100644
--- a/lib/coderay/scanners/ruby/patterns.rb
+++ b/lib/coderay/scanners/ruby/patterns.rb
@@ -60,7 +60,7 @@ module Scanners
QUOTE_TO_TYPE = {
'`' => :shell,
- '/'=> :regexp,
+ '/' => :regexp,
}
QUOTE_TO_TYPE.default = :string
diff --git a/rake_tasks/code_statistics.rb b/rake_tasks/code_statistics.rb
index 0a2016b..32eb3f0 100644
--- a/rake_tasks/code_statistics.rb
+++ b/rake_tasks/code_statistics.rb
@@ -156,7 +156,7 @@ private
code = calculate_code
tests = calculate_tests
- puts " Code LOC = #{code} Test LOC = #{tests} Code:Test Ratio = [1 : #{sprintf("%.2f", tests.to_f/code)}]"
+ puts " Code LOC = #{code} Test LOC = #{tests} Code:Test Ratio = [1 : #{sprintf("%.2f", tests.to_f / code)}]"
puts ""
end
diff --git a/test/unit/json_encoder.rb b/test/unit/json_encoder.rb
index 4e44a64..a3a8152 100644
--- a/test/unit/json_encoder.rb
+++ b/test/unit/json_encoder.rb
@@ -10,13 +10,13 @@ class JSONEncoderTest < Test::Unit::TestCase
$:.delete File.dirname(__FILE__)
json = CodeRay.scan('puts "Hello world!"', :ruby).json
assert_equal [
- {"type"=>"text", "text"=>"puts", "kind"=>"ident"},
- {"type"=>"text", "text"=>" ", "kind"=>"space"},
- {"type"=>"block", "action"=>"open", "kind"=>"string"},
- {"type"=>"text", "text"=>"\"", "kind"=>"delimiter"},
- {"type"=>"text", "text"=>"Hello world!", "kind"=>"content"},
- {"type"=>"text", "text"=>"\"", "kind"=>"delimiter"},
- {"type"=>"block", "action"=>"close", "kind"=>"string"},
+ { "type" => "text", "text" => "puts", "kind" => "ident" },
+ { "type" => "text", "text" => " ", "kind" => "space" },
+ { "type" => "block", "action" => "open", "kind" => "string" },
+ { "type" => "text", "text" => "\"", "kind" => "delimiter" },
+ { "type" => "text", "text" => "Hello world!", "kind" => "content" },
+ { "type" => "text", "text" => "\"", "kind" => "delimiter" },
+ { "type" => "block", "action" => "close", "kind" => "string" },
], JSON.load(json)
ensure
for path in old_load_paths - $: