diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 00000000..c76072a8
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,12 @@
+jobs:
+ build:
+ docker:
+ - image: cimg/ruby:3.3.5
+ environment:
+ RAILS_ENV: test
+ steps:
+ - checkout
+ - run: |
+ bundle install
+ - run: |
+ bundle exec rake test
diff --git a/.codeclimate.yml b/.codeclimate.yml
new file mode 100644
index 00000000..c01311f6
--- /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/.gitignore b/.gitignore
index deed1a27..4d962c0c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,14 +1,12 @@
-.DS_Store
-.*~
+.*
+bench/example.*
coverage
-pkg
-spec/reports
doc
Gemfile.lock
-.rvmrc
-.ruby-gemset
-.ruby-version
+old-stuff
+pkg
+spec/examples.txt
+spec/reports
test/executable/source.rb.html
test/executable/source.rb.json
test/scanners
-old-stuff
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 00000000..e248a433
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,32 @@
+inherit_from: .rubocop_todo.yml
+
+AllCops:
+ TargetRubyVersion: 2.3
+ DisplayStyleGuide: true
+ Exclude:
+ - 'test/scanners/**/*'
+ - 'bench/example.ruby'
+ - 'old-stuff/**/*'
+ - 'test/lib/**/*'
+
+Gemspec/RequiredRubyVersion:
+ Enabled: false
+
+Gemspec/DuplicatedAssignment:
+ Enabled: false
+
+Layout/AccessModifierIndentation:
+ Enabled: false
+
+Layout/AlignArguments:
+ Enabled: false
+
+Layout/AlignArray:
+ Enabled: false
+
+Layout/AlignHash:
+ Enabled: false
+
+Layout/SpaceInsideBlockBraces:
+ EnforcedStyle: space
+ EnforcedStyleForEmptyBraces: space
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
new file mode 100644
index 00000000..2b0c3708
--- /dev/null
+++ b/.rubocop_todo.yml
@@ -0,0 +1,1183 @@
+# This configuration was generated by
+# `rubocop --auto-gen-config`
+# on 2019-11-24 03:18:41 +0100 using RuboCop version 0.76.0.
+# The point is for the user to remove these configuration records
+# one by one as the offenses are removed from the code base.
+# Note that changes in the inspected code, or installation of new
+# versions of RuboCop, may require this file to be generated again.
+
+# Offense count: 26
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
+# SupportedStyles: case, end
+Layout/CaseIndentation:
+ Exclude:
+ - 'lib/coderay/scanners/css.rb'
+ - 'lib/coderay/scanners/sass.rb'
+ - 'lib/coderay/scanners/yaml.rb'
+
+# Offense count: 4
+# Cop supports --auto-correct.
+Layout/CommentIndentation:
+ Exclude:
+ - 'bin/coderay'
+ - 'lib/coderay/encoders/html/output.rb'
+ - 'lib/coderay/scanners/lua.rb'
+
+# Offense count: 82
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: leading, trailing
+Layout/DotPosition:
+ Enabled: false
+
+# Offense count: 1
+# Cop supports --auto-correct.
+# Configuration parameters: AllowBorderComment, AllowMarginComment.
+Layout/EmptyComment:
+ Exclude:
+ - 'ideosyncratic-ruby.rb'
+
+# Offense count: 30
+# Cop supports --auto-correct.
+Layout/EmptyLineAfterGuardClause:
+ Exclude:
+ - 'lib/coderay/encoders/debug_lint.rb'
+ - 'lib/coderay/encoders/encoder.rb'
+ - 'lib/coderay/encoders/html/css.rb'
+ - 'lib/coderay/encoders/html/numbering.rb'
+ - 'lib/coderay/encoders/html/output.rb'
+ - 'lib/coderay/encoders/lint.rb'
+ - 'lib/coderay/encoders/xml.rb'
+ - 'lib/coderay/helpers/file_type.rb'
+ - 'lib/coderay/helpers/plugin_host.rb'
+ - 'lib/coderay/scanners/diff.rb'
+ - 'lib/coderay/scanners/scanner.rb'
+ - 'lib/coderay/scanners/yaml.rb'
+ - 'lib/coderay/tokens.rb'
+ - 'rake_tasks/generator.rake'
+ - 'rake_tasks/test.rake'
+
+# Offense count: 6
+# Cop supports --auto-correct.
+Layout/EmptyLineAfterMagicComment:
+ Exclude:
+ - 'lib/coderay.rb'
+ - 'lib/coderay/scanners/clojure.rb'
+ - 'lib/coderay/scanners/php.rb'
+ - 'lib/coderay/scanners/ruby/patterns.rb'
+ - 'lib/coderay/scanners/ruby/string_state.rb'
+ - 'test/functional/basic.rb'
+
+# Offense count: 6
+# Cop supports --auto-correct.
+# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
+Layout/EmptyLineBetweenDefs:
+ Exclude:
+ - 'lib/coderay/for_redcloth.rb'
+ - 'lib/coderay/tokens.rb'
+
+# Offense count: 9
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: around, only_before
+Layout/EmptyLinesAroundAccessModifier:
+ Exclude:
+ - 'lib/coderay/encoders/filter.rb'
+ - 'lib/coderay/encoders/json.rb'
+ - 'lib/coderay/encoders/text.rb'
+ - 'lib/coderay/encoders/token_kind_filter.rb'
+ - 'lib/coderay/encoders/xml.rb'
+ - 'lib/coderay/encoders/yaml.rb'
+
+# Offense count: 18
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
+Layout/EmptyLinesAroundClassBody:
+ Exclude:
+ - 'lib/coderay/duo.rb'
+ - 'lib/coderay/encoders/html/css.rb'
+ - 'lib/coderay/encoders/html/output.rb'
+ - 'lib/coderay/scanners/c.rb'
+ - 'lib/coderay/scanners/cpp.rb'
+ - 'lib/coderay/scanners/delphi.rb'
+ - 'lib/coderay/scanners/java.rb'
+ - 'lib/coderay/scanners/xml.rb'
+ - 'rake_tasks/code_statistics.rb'
+
+# Offense count: 3
+# Cop supports --auto-correct.
+Layout/EmptyLinesAroundMethodBody:
+ Exclude:
+ - 'lib/coderay/scanners/c.rb'
+ - 'lib/coderay/scanners/cpp.rb'
+ - 'lib/coderay/scanners/java.rb'
+
+# Offense count: 16
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
+Layout/EmptyLinesAroundModuleBody:
+ Exclude:
+ - 'lib/coderay/encoders/html/css.rb'
+ - 'lib/coderay/encoders/html/output.rb'
+ - 'lib/coderay/scanners/c.rb'
+ - 'lib/coderay/scanners/cpp.rb'
+ - 'lib/coderay/scanners/css.rb'
+ - 'lib/coderay/scanners/delphi.rb'
+ - 'lib/coderay/scanners/java.rb'
+ - 'lib/coderay/scanners/lua.rb'
+ - 'lib/coderay/scanners/xml.rb'
+ - 'lib/coderay/styles.rb'
+
+# Offense count: 5
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
+# SupportedStylesAlignWith: keyword, variable, start_of_line
+Layout/EndAlignment:
+ Exclude:
+ - 'lib/coderay/scanners/css.rb'
+ - 'lib/coderay/scanners/sass.rb'
+ - 'lib/coderay/scanners/yaml.rb'
+
+# Offense count: 2
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: native, lf, crlf
+Layout/EndOfLine:
+ Exclude:
+ - 'rake_tasks/documentation.rake'
+ - 'rake_tasks/statistic.rake'
+
+# Offense count: 140
+# Cop supports --auto-correct.
+# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
+Layout/ExtraSpacing:
+ Enabled: false
+
+# Offense count: 2
+# Cop supports --auto-correct.
+# Configuration parameters: IndentationWidth.
+# SupportedStyles: special_inside_parentheses, consistent, align_brackets
+Layout/IndentFirstArrayElement:
+ EnforcedStyle: consistent
+
+# Offense count: 4
+# Cop supports --auto-correct.
+# Configuration parameters: IndentationWidth.
+# SupportedStyles: special_inside_parentheses, consistent, align_braces
+Layout/IndentFirstHashElement:
+ EnforcedStyle: consistent
+
+# Offense count: 48
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: squiggly, active_support, powerpack, unindent
+Layout/IndentHeredoc:
+ Enabled: false
+
+# Offense count: 53
+# Cop supports --auto-correct.
+# Configuration parameters: Width, IgnoredPatterns.
+Layout/IndentationWidth:
+ Enabled: false
+
+# Offense count: 1
+# Cop supports --auto-correct.
+# Configuration parameters: AllowDoxygenCommentStyle.
+Layout/LeadingCommentSpace:
+ Exclude:
+ - 'lib/coderay/scanners/html.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: symmetrical, new_line, same_line
+Layout/MultilineArrayBraceLayout:
+ Exclude:
+ - 'lib/coderay/scanners/lua.rb'
+
+# Offense count: 78
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle, IndentationWidth.
+# SupportedStyles: aligned, indented, indented_relative_to_receiver
+Layout/MultilineMethodCallIndentation:
+ Enabled: false
+
+# Offense count: 9
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle, IndentationWidth.
+# SupportedStyles: aligned, indented
+Layout/MultilineOperationIndentation:
+ Exclude:
+ - 'lib/coderay/encoders/html/numbering.rb'
+ - 'lib/coderay/encoders/token_kind_filter.rb'
+ - 'lib/coderay/for_redcloth.rb'
+ - 'lib/coderay/scanners/groovy.rb'
+ - 'lib/coderay/scanners/php.rb'
+ - 'lib/coderay/scanners/ruby.rb'
+ - 'test/functional/basic.rb'
+
+# Offense count: 17
+# Cop supports --auto-correct.
+Layout/SpaceAfterComma:
+ Exclude:
+ - 'ideosyncratic-ruby.rb'
+ - 'lib/coderay/encoders/html/output.rb'
+ - 'lib/coderay/helpers/plugin_host.rb'
+ - 'lib/coderay/scanners/css.rb'
+ - 'lib/coderay/scanners/diff.rb'
+ - 'lib/coderay/scanners/ruby.rb'
+ - 'lib/coderay/scanners/ruby/string_state.rb'
+ - 'lib/coderay/scanners/sass.rb'
+ - 'lib/coderay/scanners/yaml.rb'
+ - 'lib/coderay/token_kinds.rb'
+
+# Offense count: 37
+# Cop supports --auto-correct.
+# Configuration parameters: AllowForAlignment.
+Layout/SpaceAroundOperators:
+ AllowForAlignment: true
+
+# Offense count: 2
+# Cop supports --auto-correct.
+Layout/SpaceBeforeComment:
+ Exclude:
+ - 'ideosyncratic-ruby.rb'
+ - 'lib/coderay/token_kinds.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Layout/SpaceBeforeSemicolon:
+ Exclude:
+ - 'lib/coderay/scanners/diff.rb'
+
+# Offense count: 17
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
+# SupportedStyles: space, no_space, compact
+# SupportedStylesForEmptyBraces: space, no_space
+Layout/SpaceInsideHashLiteralBraces:
+ Exclude:
+ - 'lib/coderay/encoders/encoder.rb'
+ - 'lib/coderay/scanners/scanner.rb'
+ - 'lib/coderay/styles/style.rb'
+ - 'test/unit/json_encoder.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: space, no_space
+Layout/SpaceInsideParens:
+ Exclude:
+ - 'rake_tasks/code_statistics.rb'
+
+# Offense count: 32
+# Cop supports --auto-correct.
+Layout/SpaceInsidePercentLiteralDelimiters:
+ Exclude:
+ - 'lib/coderay/scanners/clojure.rb'
+ - 'lib/coderay/scanners/groovy.rb'
+ - 'lib/coderay/scanners/java.rb'
+ - 'lib/coderay/scanners/java_script.rb'
+ - 'lib/coderay/scanners/php.rb'
+ - 'lib/coderay/scanners/ruby/patterns.rb'
+ - 'lib/coderay/scanners/sql.rb'
+
+# Offense count: 3
+# Cop supports --auto-correct.
+Layout/SpaceInsideRangeLiteral:
+ Exclude:
+ - 'lib/coderay/encoders/html/css.rb'
+ - 'lib/coderay/encoders/html/numbering.rb'
+
+# Offense count: 2
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
+# SupportedStyles: space, no_space
+# SupportedStylesForEmptyBrackets: space, no_space
+Layout/SpaceInsideReferenceBrackets:
+ Exclude:
+ - 'lib/coderay/scanners/ruby/string_state.rb'
+
+# Offense count: 6
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: space, no_space
+Layout/SpaceInsideStringInterpolation:
+ Exclude:
+ - 'ideosyncratic-ruby.rb'
+ - 'lib/coderay/scanners/ruby/string_state.rb'
+
+# Offense count: 12
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: final_newline, final_blank_line
+Layout/TrailingBlankLines:
+ Exclude:
+ - 'lib/coderay/for_redcloth.rb'
+ - 'lib/coderay/scanners/clojure.rb'
+ - 'test/executable/source.rb'
+ - 'test/functional/for_redcloth.rb'
+ - 'test/unit/comment_filter.rb'
+ - 'test/unit/count.rb'
+ - 'test/unit/json_encoder.rb'
+ - 'test/unit/lines_of_code.rb'
+ - 'test/unit/null.rb'
+ - 'test/unit/statistic.rb'
+ - 'test/unit/text.rb'
+ - 'test/unit/tokens.rb'
+
+# Offense count: 1680
+# Cop supports --auto-correct.
+# Configuration parameters: AllowInHeredoc.
+Layout/TrailingWhitespace:
+ Enabled: false
+
+# Offense count: 485
+# Configuration parameters: AllowSafeAssignment.
+Lint/AssignmentInCondition:
+ Enabled: false
+
+# Offense count: 2
+# Configuration parameters: AllowComments.
+Lint/HandleExceptions:
+ Exclude:
+ - 'bin/coderay'
+ - 'lib/coderay/scanners/ruby.rb'
+
+# Offense count: 2
+Lint/IneffectiveAccessModifier:
+ Exclude:
+ - 'lib/coderay/encoders/html.rb'
+
+# Offense count: 3
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: runtime_error, standard_error
+Lint/InheritException:
+ Exclude:
+ - 'lib/coderay/helpers/file_type.rb'
+ - 'lib/coderay/helpers/plugin_host.rb'
+
+# Offense count: 3
+Lint/LiteralAsCondition:
+ Exclude:
+ - 'ideosyncratic-ruby.rb'
+ - 'lib/coderay/scanners/haml.rb'
+ - 'test/executable/suite.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Lint/LiteralInInterpolation:
+ Exclude:
+ - 'ideosyncratic-ruby.rb'
+
+# Offense count: 2
+Lint/Loop:
+ Exclude:
+ - 'lib/coderay/helpers/plugin_host.rb'
+ - 'lib/coderay/tokens.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Lint/RedundantSplatExpansion:
+ Exclude:
+ - 'lib/coderay/scanners/ruby/string_state.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Lint/SendWithMixinArgument:
+ Exclude:
+ - 'lib/coderay/for_redcloth.rb'
+
+# Offense count: 1
+# Configuration parameters: IgnoreImplicitReferences.
+Lint/ShadowedArgument:
+ Exclude:
+ - 'lib/coderay/for_redcloth.rb'
+
+# Offense count: 4
+# Cop supports --auto-correct.
+# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
+Lint/UnusedBlockArgument:
+ Exclude:
+ - 'lib/coderay/encoders/statistic.rb'
+ - 'lib/coderay/scanners/diff.rb'
+ - 'rake_tasks/code_statistics.rb'
+
+# Offense count: 38
+# Cop supports --auto-correct.
+# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
+Lint/UnusedMethodArgument:
+ Enabled: false
+
+# Offense count: 8
+Lint/UselessAssignment:
+ Exclude:
+ - 'lib/coderay/scanners/sql.rb'
+ - 'lib/coderay/scanners/yaml.rb'
+ - 'rake_tasks/code_statistics.rb'
+ - 'test/executable/suite.rb'
+
+# Offense count: 7
+# Configuration parameters: CheckForMethodsWithNoSideEffects.
+Lint/Void:
+ Exclude:
+ - 'ideosyncratic-ruby.rb'
+
+# Offense count: 49
+Metrics/AbcSize:
+ Max: 361
+
+# Offense count: 5
+# Configuration parameters: CountComments, ExcludedMethods.
+# ExcludedMethods: refine
+Metrics/BlockLength:
+ Max: 71
+
+# Offense count: 183
+# Configuration parameters: CountBlocks.
+Metrics/BlockNesting:
+ Max: 8
+
+# Offense count: 27
+# Configuration parameters: CountComments.
+Metrics/ClassLength:
+ Max: 380
+
+# Offense count: 34
+Metrics/CyclomaticComplexity:
+ Max: 148
+
+# Offense count: 63
+# Configuration parameters: CountComments, ExcludedMethods.
+Metrics/MethodLength:
+ Max: 366
+
+# Offense count: 5
+# Configuration parameters: CountComments.
+Metrics/ModuleLength:
+ Max: 410
+
+# Offense count: 34
+Metrics/PerceivedComplexity:
+ Max: 161
+
+# Offense count: 2
+Naming/AccessorMethodName:
+ Exclude:
+ - 'lib/coderay/scanners/scanner.rb'
+
+# Offense count: 24
+Naming/ConstantName:
+ Exclude:
+ - 'lib/coderay/helpers/file_type.rb'
+ - 'lib/coderay/scanners/css.rb'
+ - 'lib/coderay/scanners/java/builtin_types.rb'
+
+# Offense count: 1
+# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
+# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
+Naming/FileName:
+ Exclude:
+ - 'ideosyncratic-ruby.rb'
+
+# Offense count: 1
+# Configuration parameters: EnforcedStyleForLeadingUnderscores.
+# SupportedStylesForLeadingUnderscores: disallowed, required, optional
+Naming/MemoizedInstanceVariableName:
+ Exclude:
+ - 'lib/coderay/scanners/scanner.rb'
+
+# Offense count: 2
+# Cop supports --auto-correct.
+# Configuration parameters: PreferredName.
+Naming/RescuedExceptionsVariableName:
+ Exclude:
+ - 'bin/coderay'
+ - 'lib/coderay/helpers/plugin_host.rb'
+
+# Offense count: 5
+# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
+# AllowedNames: io, id, to, by, on, in, at, ip, db, os
+Naming/UncommunicativeMethodParamName:
+ Exclude:
+ - 'lib/coderay/encoders/html/output.rb'
+ - 'lib/coderay/scanners/diff.rb'
+ - 'lib/coderay/scanners/scanner.rb'
+
+# Offense count: 8
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: snake_case, camelCase
+Naming/VariableName:
+ Exclude:
+ - 'lib/coderay/encoders/encoder.rb'
+ - 'lib/coderay/encoders/html.rb'
+ - 'test/functional/basic.rb'
+
+# Offense count: 2
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: snake_case, normalcase, non_integer
+Naming/VariableNumber:
+ Exclude:
+ - 'test/unit/tokens.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+# Configuration parameters: AutoCorrect.
+Security/JSONLoad:
+ Exclude:
+ - 'test/unit/json_encoder.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Security/YAMLLoad:
+ Exclude:
+ - 'test/unit/duo.rb'
+
+# Offense count: 1
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: inline, group
+Style/AccessModifierDeclarations:
+ Exclude:
+ - 'lib/coderay/encoders/encoder.rb'
+
+# Offense count: 8
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: always, conditionals
+Style/AndOr:
+ Exclude:
+ - 'lib/coderay/encoders/html/output.rb'
+ - 'lib/coderay/scanners/clojure.rb'
+ - 'lib/coderay/scanners/erb.rb'
+ - 'lib/coderay/scanners/lua.rb'
+ - 'lib/coderay/scanners/yaml.rb'
+
+# Offense count: 9
+# Configuration parameters: AllowedChars.
+Style/AsciiComments:
+ Exclude:
+ - 'lib/coderay/scanners/lua.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Style/Attr:
+ Exclude:
+ - 'lib/coderay/encoders/html/css.rb'
+
+# Offense count: 2
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners.
+# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
+# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
+# FunctionalMethods: let, let!, subject, watch
+# IgnoredMethods: lambda, proc, it
+Style/BlockDelimiters:
+ Exclude:
+ - 'lib/coderay/scanners/python.rb'
+
+# Offense count: 2
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: braces, no_braces, context_dependent
+Style/BracesAroundHashParameters:
+ Exclude:
+ - 'lib/coderay/scanners/ruby/patterns.rb'
+
+# Offense count: 3
+Style/CaseEquality:
+ Exclude:
+ - 'bin/coderay'
+ - 'rake_tasks/generator.rake'
+ - 'test/executable/suite.rb'
+
+# Offense count: 35
+# Cop supports --auto-correct.
+Style/CharacterLiteral:
+ Exclude:
+ - 'ideosyncratic-ruby.rb'
+ - 'lib/coderay/encoders/html/numbering.rb'
+ - 'lib/coderay/scanners/c.rb'
+ - 'lib/coderay/scanners/cpp.rb'
+ - 'lib/coderay/scanners/css.rb'
+ - 'lib/coderay/scanners/go.rb'
+ - 'lib/coderay/scanners/groovy.rb'
+ - 'lib/coderay/scanners/java_script.rb'
+ - 'lib/coderay/scanners/python.rb'
+ - 'lib/coderay/scanners/ruby.rb'
+ - 'lib/coderay/scanners/sass.rb'
+ - 'lib/coderay/scanners/scanner.rb'
+ - 'lib/coderay/scanners/sql.rb'
+ - 'lib/coderay/scanners/yaml.rb'
+
+# Offense count: 3
+# Cop supports --auto-correct.
+# Configuration parameters: AutoCorrect, EnforcedStyle.
+# SupportedStyles: nested, compact
+Style/ClassAndModuleChildren:
+ Exclude:
+ - 'lib/coderay/helpers/word_list.rb'
+ - 'lib/coderay/scanners/java/builtin_types.rb'
+ - 'lib/coderay/scanners/ruby/patterns.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Style/ClassMethods:
+ Exclude:
+ - 'lib/coderay/encoders/html/css.rb'
+
+# Offense count: 2
+Style/ClassVars:
+ Exclude:
+ - 'lib/coderay/encoders/encoder.rb'
+
+# Offense count: 2
+Style/CommentedKeyword:
+ Exclude:
+ - 'lib/coderay/scanners/scanner.rb'
+
+# Offense count: 16
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
+# SupportedStyles: assign_to_condition, assign_inside_condition
+Style/ConditionalAssignment:
+ Exclude:
+ - 'bin/coderay'
+ - 'coderay.gemspec'
+ - 'lib/coderay/encoders/html.rb'
+ - 'lib/coderay/encoders/html/numbering.rb'
+ - 'lib/coderay/encoders/xml.rb'
+ - 'lib/coderay/scanners/debug.rb'
+ - 'lib/coderay/scanners/html.rb'
+ - 'lib/coderay/scanners/java_script.rb'
+ - 'lib/coderay/scanners/php.rb'
+ - 'lib/coderay/scanners/raydebug.rb'
+ - 'lib/coderay/scanners/scanner.rb'
+ - 'rake_tasks/code_statistics.rb'
+ - 'test/executable/suite.rb'
+
+# Offense count: 21
+Style/Documentation:
+ Enabled: false
+
+# Offense count: 2
+Style/DoubleNegation:
+ Exclude:
+ - 'lib/coderay/scanners/python.rb'
+ - 'lib/coderay/scanners/ruby.rb'
+
+# Offense count: 4
+# Cop supports --auto-correct.
+Style/EachWithObject:
+ Exclude:
+ - 'bin/coderay'
+ - 'lib/coderay/helpers/plugin.rb'
+ - 'rake_tasks/code_statistics.rb'
+
+# Offense count: 4
+# Cop supports --auto-correct.
+Style/EmptyCaseCondition:
+ Exclude:
+ - 'lib/coderay/encoders/xml.rb'
+ - 'lib/coderay/scanners/yaml.rb'
+
+# Offense count: 2
+# Cop supports --auto-correct.
+Style/EmptyLiteral:
+ Exclude:
+ - 'lib/coderay/encoders/html/css.rb'
+
+# Offense count: 5
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: compact, expanded
+Style/EmptyMethod:
+ Exclude:
+ - 'lib/coderay/encoders/encoder.rb'
+ - 'lib/coderay/scanners/scanner.rb'
+
+# Offense count: 8
+# Cop supports --auto-correct.
+Style/Encoding:
+ Exclude:
+ - 'lib/coderay.rb'
+ - 'lib/coderay/scanners/clojure.rb'
+ - 'lib/coderay/scanners/lua.rb'
+ - 'lib/coderay/scanners/php.rb'
+ - 'lib/coderay/scanners/ruby/patterns.rb'
+ - 'lib/coderay/scanners/ruby/string_state.rb'
+ - 'lib/coderay/scanners/scanner.rb'
+ - 'test/functional/basic.rb'
+
+# Offense count: 12
+# Cop supports --auto-correct.
+Style/ExpandPathArguments:
+ Exclude:
+ - 'bench/bench.rb'
+ - 'coderay.gemspec'
+ - 'lib/coderay.rb'
+ - 'test/executable/suite.rb'
+ - 'test/functional/basic.rb'
+ - 'test/functional/examples.rb'
+ - 'test/functional/for_redcloth.rb'
+ - 'test/functional/suite.rb'
+ - 'test/unit/file_type.rb'
+ - 'test/unit/lines_of_code.rb'
+ - 'test/unit/plugin.rb'
+
+# Offense count: 22
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: each, for
+Style/For:
+ Exclude:
+ - 'Rakefile'
+ - 'lib/coderay/encoders/encoder.rb'
+ - 'lib/coderay/encoders/html/css.rb'
+ - 'lib/coderay/helpers/file_type.rb'
+ - 'lib/coderay/helpers/plugin_host.rb'
+ - 'lib/coderay/scanners/diff.rb'
+ - 'lib/coderay/tokens.rb'
+ - 'rake_tasks/generator.rake'
+ - 'rake_tasks/test.rake'
+ - 'test/functional/basic.rb'
+ - 'test/functional/suite.rb'
+ - 'test/unit/html.rb'
+ - 'test/unit/json_encoder.rb'
+ - 'test/unit/suite.rb'
+ - 'test/unit/token_kind_filter.rb'
+
+# Offense count: 62
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: format, sprintf, percent
+Style/FormatString:
+ Enabled: false
+
+# Offense count: 87
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: annotated, template, unannotated
+Style/FormatStringToken:
+ Enabled: false
+
+# Offense count: 112
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: always, never
+Style/FrozenStringLiteralComment:
+ Enabled: false
+
+# Offense count: 9
+# Configuration parameters: AllowedVariables.
+Style/GlobalVars:
+ Exclude:
+ - 'bin/coderay'
+ - 'lib/coderay.rb'
+ - 'lib/coderay/encoders/html.rb'
+ - 'lib/coderay/scanners/ruby.rb'
+ - 'test/functional/suite.rb'
+ - 'test/unit/suite.rb'
+
+# Offense count: 16
+# Configuration parameters: MinBodyLength.
+Style/GuardClause:
+ Exclude:
+ - 'lib/coderay/encoders/html.rb'
+ - 'lib/coderay/encoders/html/output.rb'
+ - 'lib/coderay/encoders/terminal.rb'
+ - 'lib/coderay/helpers/plugin_host.rb'
+ - 'lib/coderay/scanners/haml.rb'
+ - 'lib/coderay/scanners/html.rb'
+ - 'lib/coderay/scanners/python.rb'
+ - 'lib/coderay/scanners/scanner.rb'
+ - 'test/executable/suite.rb'
+ - 'test/unit/file_type.rb'
+
+# Offense count: 306
+# Cop supports --auto-correct.
+# Configuration parameters: UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
+# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
+Style/HashSyntax:
+ EnforcedStyle: hash_rockets
+
+# Offense count: 4
+Style/IdenticalConditionalBranches:
+ Exclude:
+ - 'lib/coderay/scanners/html.rb'
+ - 'lib/coderay/scanners/ruby.rb'
+
+# Offense count: 2
+# Configuration parameters: AllowIfModifier.
+Style/IfInsideElse:
+ Exclude:
+ - 'lib/coderay/scanners/css.rb'
+ - 'lib/coderay/scanners/sass.rb'
+
+# Offense count: 42
+# Cop supports --auto-correct.
+Style/IfUnlessModifier:
+ Enabled: false
+
+# Offense count: 3
+Style/IfUnlessModifierOfIfUnless:
+ Exclude:
+ - 'lib/coderay/encoders/text.rb'
+ - 'lib/coderay/scanners/erb.rb'
+ - 'rake_tasks/test.rake'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Style/InfiniteLoop:
+ Exclude:
+ - 'lib/coderay/scanners/haml.rb'
+
+# Offense count: 2
+# Cop supports --auto-correct.
+Style/LineEndConcatenation:
+ Exclude:
+ - 'lib/coderay/for_redcloth.rb'
+ - 'test/functional/basic.rb'
+
+# Offense count: 221
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline
+Style/MethodDefParentheses:
+ Enabled: false
+
+# Offense count: 1
+Style/MethodMissingSuper:
+ Exclude:
+ - 'lib/coderay/tokens_proxy.rb'
+
+# Offense count: 2
+Style/MissingRespondToMissing:
+ Exclude:
+ - 'lib/coderay/tokens.rb'
+ - 'lib/coderay/tokens_proxy.rb'
+
+# Offense count: 1
+Style/MultilineBlockChain:
+ Exclude:
+ - 'lib/coderay/helpers/plugin_host.rb'
+
+# Offense count: 5
+# Cop supports --auto-correct.
+Style/MultilineIfModifier:
+ Exclude:
+ - 'lib/coderay/encoders/text.rb'
+ - 'lib/coderay/scanners/erb.rb'
+ - 'rake_tasks/documentation.rake'
+ - 'rake_tasks/test.rake'
+ - 'test/functional/for_redcloth.rb'
+
+# Offense count: 10
+Style/MultilineTernaryOperator:
+ Exclude:
+ - 'lib/coderay/scanners/ruby.rb'
+
+# Offense count: 7
+Style/MultipleComparison:
+ Exclude:
+ - 'lib/coderay/scanners/groovy.rb'
+ - 'lib/coderay/scanners/html.rb'
+ - 'lib/coderay/scanners/java.rb'
+ - 'lib/coderay/scanners/java_script.rb'
+ - 'lib/coderay/scanners/sass.rb'
+ - 'lib/coderay/scanners/yaml.rb'
+
+# Offense count: 247
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: literals, strict
+Style/MutableConstant:
+ Enabled: false
+
+# Offense count: 2
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: both, prefix, postfix
+Style/NegatedIf:
+ Exclude:
+ - 'lib/coderay/scanners/diff.rb'
+ - 'lib/coderay/scanners/groovy.rb'
+
+# Offense count: 6
+Style/NestedTernaryOperator:
+ Exclude:
+ - 'Gemfile'
+ - 'lib/coderay/scanners/php.rb'
+ - 'lib/coderay/scanners/python.rb'
+ - 'lib/coderay/scanners/sass.rb'
+ - 'lib/coderay/scanners/sql.rb'
+
+# Offense count: 2
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: predicate, comparison
+Style/NilComparison:
+ Exclude:
+ - 'lib/coderay/encoders/html/numbering.rb'
+ - 'lib/coderay/scanners/python.rb'
+
+# Offense count: 3
+# Cop supports --auto-correct.
+Style/Not:
+ Exclude:
+ - 'lib/coderay/encoders/html/output.rb'
+ - 'lib/coderay/scanners/clojure.rb'
+ - 'lib/coderay/scanners/erb.rb'
+
+# Offense count: 12
+# Cop supports --auto-correct.
+# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
+# SupportedStyles: predicate, comparison
+Style/NumericPredicate:
+ Exclude:
+ - 'spec/**/*'
+ - 'lib/coderay/encoders/html.rb'
+ - 'lib/coderay/encoders/html/numbering.rb'
+ - 'lib/coderay/scanners/diff.rb'
+ - 'lib/coderay/scanners/groovy.rb'
+ - 'lib/coderay/scanners/haml.rb'
+ - 'lib/coderay/scanners/lua.rb'
+ - 'lib/coderay/scanners/ruby.rb'
+ - 'lib/coderay/tokens.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Style/OneLineConditional:
+ Exclude:
+ - 'rake_tasks/code_statistics.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Style/OrAssignment:
+ Exclude:
+ - 'lib/coderay/scanners/groovy.rb'
+
+# Offense count: 2
+# Cop supports --auto-correct.
+Style/ParallelAssignment:
+ Exclude:
+ - 'lib/coderay/encoders/statistic.rb'
+ - 'lib/coderay/scanners/ruby.rb'
+
+# Offense count: 30
+# Cop supports --auto-correct.
+# Configuration parameters: PreferredDelimiters.
+Style/PercentLiteralDelimiters:
+ Enabled: false
+
+# Offense count: 6
+# Cop supports --auto-correct.
+Style/PerlBackrefs:
+ Exclude:
+ - 'bin/coderay'
+ - 'lib/coderay/encoders/html/output.rb'
+ - 'lib/coderay/for_redcloth.rb'
+
+# Offense count: 5
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: short, verbose
+Style/PreferredHashMethods:
+ Exclude:
+ - 'lib/coderay/encoders/debug_lint.rb'
+ - 'lib/coderay/encoders/lint.rb'
+ - 'lib/coderay/helpers/plugin_host.rb'
+
+# Offense count: 3
+# Cop supports --auto-correct.
+# Configuration parameters: AllowMultipleReturnValues.
+Style/RedundantReturn:
+ Exclude:
+ - 'lib/coderay/encoders/html/css.rb'
+ - 'lib/coderay/scanners/diff.rb'
+ - 'lib/coderay/scanners/scanner.rb'
+
+# Offense count: 3
+# Cop supports --auto-correct.
+Style/RedundantSelf:
+ Exclude:
+ - 'lib/coderay/encoders/html/output.rb'
+ - 'lib/coderay/helpers/plugin_host.rb'
+ - 'lib/coderay/scanners/scanner.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Style/RedundantSort:
+ Exclude:
+ - 'test/unit/plugin.rb'
+
+# Offense count: 58
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
+# SupportedStyles: slashes, percent_r, mixed
+Style/RegexpLiteral:
+ Enabled: false
+
+# Offense count: 4
+# Cop supports --auto-correct.
+Style/RescueModifier:
+ Exclude:
+ - 'rake_tasks/code_statistics.rb'
+ - 'rake_tasks/test.rake'
+ - 'test/functional/for_redcloth.rb'
+
+# Offense count: 2
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: implicit, explicit
+Style/RescueStandardError:
+ Exclude:
+ - 'lib/coderay/scanners/ruby.rb'
+ - 'lib/coderay/scanners/scanner.rb'
+
+# Offense count: 4
+# Cop supports --auto-correct.
+# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist.
+# Whitelist: present?, blank?, presence, try, try!
+Style/SafeNavigation:
+ Exclude:
+ - 'bin/coderay'
+ - 'lib/coderay/scanners/ruby.rb'
+
+# Offense count: 3
+# Cop supports --auto-correct.
+# Configuration parameters: AllowAsExpressionSeparator.
+Style/Semicolon:
+ Exclude:
+ - 'lib/coderay/scanners/diff.rb'
+ - 'lib/coderay/scanners/ruby/string_state.rb'
+
+# Offense count: 4
+# Cop supports --auto-correct.
+# Configuration parameters: AllowIfMethodIsEmpty.
+Style/SingleLineMethods:
+ Exclude:
+ - 'lib/coderay/tokens.rb'
+
+# Offense count: 24
+# Cop supports --auto-correct.
+# Configuration parameters: .
+# SupportedStyles: use_perl_names, use_english_names
+Style/SpecialGlobalVars:
+ EnforcedStyle: use_perl_names
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Style/StderrPuts:
+ Exclude:
+ - 'lib/coderay/encoders/json.rb'
+
+# Offense count: 131
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
+# SupportedStyles: single_quotes, double_quotes
+Style/StringLiterals:
+ Enabled: false
+
+# Offense count: 1
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: single_quotes, double_quotes
+Style/StringLiteralsInInterpolation:
+ Exclude:
+ - 'rake_tasks/code_statistics.rb'
+
+# Offense count: 1
+Style/StructInheritance:
+ Exclude:
+ - 'lib/coderay/scanners/ruby/string_state.rb'
+
+# Offense count: 37
+# Cop supports --auto-correct.
+# Configuration parameters: MinSize.
+# SupportedStyles: percent, brackets
+Style/SymbolArray:
+ EnforcedStyle: brackets
+
+# Offense count: 4
+# Cop supports --auto-correct.
+# Configuration parameters: IgnoredMethods.
+# IgnoredMethods: respond_to, define_method
+Style/SymbolProc:
+ Exclude:
+ - 'bin/coderay'
+ - 'lib/coderay/scanners/scanner.rb'
+ - 'test/unit/plugin.rb'
+
+# Offense count: 1
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
+# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
+Style/TernaryParentheses:
+ Exclude:
+ - 'lib/coderay/scanners/diff.rb'
+
+# Offense count: 21
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyleForMultiline.
+# SupportedStylesForMultiline: comma, consistent_comma, no_comma
+Style/TrailingCommaInArrayLiteral:
+ Exclude:
+ - 'lib/coderay/scanners/c.rb'
+ - 'lib/coderay/scanners/cpp.rb'
+ - 'lib/coderay/scanners/css.rb'
+ - 'lib/coderay/scanners/delphi.rb'
+ - 'lib/coderay/scanners/go.rb'
+ - 'lib/coderay/scanners/html.rb'
+ - 'lib/coderay/scanners/json.rb'
+ - 'lib/coderay/scanners/python.rb'
+ - 'lib/coderay/scanners/scanner.rb'
+ - 'test/unit/json_encoder.rb'
+
+# Offense count: 26
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyleForMultiline.
+# SupportedStylesForMultiline: comma, consistent_comma, no_comma
+Style/TrailingCommaInHashLiteral:
+ Exclude:
+ - 'lib/coderay/encoders/html.rb'
+ - 'lib/coderay/encoders/terminal.rb'
+ - 'lib/coderay/encoders/xml.rb'
+ - 'lib/coderay/for_redcloth.rb'
+ - 'lib/coderay/helpers/file_type.rb'
+ - 'lib/coderay/scanners/diff.rb'
+ - 'lib/coderay/scanners/groovy.rb'
+ - 'lib/coderay/scanners/html.rb'
+ - 'lib/coderay/scanners/java.rb'
+ - 'lib/coderay/scanners/java_script.rb'
+ - 'lib/coderay/scanners/ruby/patterns.rb'
+ - 'lib/coderay/scanners/sql.rb'
+
+# Offense count: 3
+# Cop supports --auto-correct.
+Style/VariableInterpolation:
+ Exclude:
+ - 'bin/coderay'
+ - 'ideosyncratic-ruby.rb'
+
+# Offense count: 10
+# Cop supports --auto-correct.
+# Configuration parameters: WordRegex.
+# SupportedStyles: percent, brackets
+Style/WordArray:
+ EnforcedStyle: percent
+ MinSize: 69
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Style/ZeroLengthPredicate:
+ Exclude:
+ - 'lib/coderay/encoders/html.rb'
+
+# Offense count: 813
+# Cop supports --auto-correct.
+# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
+# URISchemes: http, https
+Metrics/LineLength:
+ Max: 266
diff --git a/.simplecov b/.simplecov
new file mode 100644
index 00000000..f498df81
--- /dev/null
+++ b/.simplecov
@@ -0,0 +1,4 @@
+unless RUBY_VERSION[/^2.3/]
+ SimpleCov.command_name $0
+ SimpleCov.start
+end
diff --git a/.travis.yml b/.travis.yml
index f8156982..6c607d27 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,9 @@
+env:
+ global:
+ - "JRUBY_OPTS=-Xcext.enabled=true"
+ - "CC_TEST_REPORTER_ID=faa393209ff0a104cf37511a9a03510bcee37951971b1ca4ffc2af217851d47e"
+language: ruby
+os: linux
rvm:
- 1.8.7
- ree
@@ -5,21 +11,30 @@ rvm:
- 2.0
- 2.1
- 2.2
- - 2.3.0
+ - 2.3
+ - 2.4
+ - 2.5
+ - 2.6
+ - 2.7
+ - 3.0
+ - 3.1
+ - 3.2
- ruby-head
- - jruby-18mode
- - jruby-19mode
- - jruby-head
- - rbx-18mode
- - rbx-19mode
+ - jruby
+jobs:
+ allow_failures:
+ - rvm: 1.8.7
+ - rvm: ree
+ - rvm: ruby-head
+ - rvm: jruby
branches:
only:
- master
-matrix:
- allow_failures:
- - rvm: ruby-head
- - rvm: jruby-head
- - rvm: rbx-18mode
- - rvm: rbx-19mode
+before_script:
+ - if (ruby -e "exit RUBY_VERSION.to_f >= 2.3"); then export RUBYOPT="--enable-frozen-string-literal"; fi; echo $RUBYOPT
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
+ - chmod +x ./cc-test-reporter
+ - ./cc-test-reporter before-build
script: "rake test" # test:scanners"
-sudo: false
+after_script:
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
diff --git a/Changes.textile b/Changes.textile
index 10f1d6eb..8c4f3e95 100644
--- a/Changes.textile
+++ b/Changes.textile
@@ -2,6 +2,20 @@ h1=. CodeRay Version History
p=. _This files lists all changes in the CodeRay library since the 0.9.8 release._
+h2. Changes in 1.1.3
+
+* Tokens: Ensure Ruby 2.6 compatibility. [#233, thanks to Jun Aruga]
+* SQL scanner: Add @numeric@ data type. [#223, thanks to m16a1]
+* Java scanner: Add @var@ as type. [#229, thanks to Davide Angelocola]
+* Gem: Fix deprecation warning. [#246, thanks to David RodrÃguez]
+
+h2. Changes in 1.1.2
+
+* Ruby future: Add support for frozen string literals. [#211, thanks to Pat Allan]
+* C++ scanner: Add C++11 keywords. [#195, thanks to Johnny Willemsen]
+* Haml scanner: Allow @-@ in tags.
+* Java scanner: Allow Unicode characters in identifiers. [#212, thanks to t-gergely]
+
h2. Changes in 1.1.1
* SQL scanner: Allow @$@ signs in SQL identifiers [#164, thanks to jasir and Ben Basson]
diff --git a/FOLDERS b/FOLDERS
index f29255ae..1709d08a 100644
--- a/FOLDERS
+++ b/FOLDERS
@@ -1,48 +1,48 @@
-= CodeRay - folder structure
-
-== bench - Benchmarking system
-
-All benchmarking stuff goes here.
-
-Test inputs are stored in files named example.
.
-Test outputs go to bench/test.
.
-
-Run bench/bench.rb
to get a usage description.
-
-Run rake bench
to perform an example benchmark.
-
-
-== bin - Scripts
-
-Executional files for CodeRay.
-
-coderay:: The CodeRay executable.
-
-== demo - Demos and functional tests
-
-Demonstrational scripts to show of CodeRay's features.
-
-Run them as functional tests with rake test:demos
.
-
-
-== etc - Lots of stuff
-
-Some addidtional files for CodeRay, mainly graphics and Vim scripts.
-
-
-== lib - CodeRay library code
-
-This is the base directory for the CodeRay library.
-
-
-== rake_helpers - Rake helper libraries
-
-Some files to enhance Rake, including the Autumnal Rdoc template and some scripts.
-
-
-== test - Tests
-
-In the subfolder scanners/ are the scanners tests.
-Each language has its own subfolder and sub-suite.
-
-Run with rake test
.
+= CodeRay - folder structure
+
+== bench - Benchmarking system
+
+All benchmarking stuff goes here.
+
+Test inputs are stored in files named example.
.
+Test outputs go to bench/test.
.
+
+Run bench/bench.rb
to get a usage description.
+
+Run rake bench
to perform an example benchmark.
+
+
+== bin - Scripts
+
+Executional files for CodeRay.
+
+coderay:: The CodeRay executable.
+
+== demo - Demos and functional tests
+
+Demonstrational scripts to show of CodeRay's features.
+
+Run them as functional tests with rake test:demos
.
+
+
+== etc - Lots of stuff
+
+Some additional files for CodeRay, mainly graphics and Vim scripts.
+
+
+== lib - CodeRay library code
+
+This is the base directory for the CodeRay library.
+
+
+== rake_helpers - Rake helper libraries
+
+Some files to enhance Rake, including the Autumnal Rdoc template and some scripts.
+
+
+== test - Tests
+
+In the subfolder scanners/ are the scanners tests.
+Each language has its own subfolder and sub-suite.
+
+Run with rake test
.
diff --git a/Gemfile b/Gemfile
index 6d3a176f..49ac338d 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,13 +6,15 @@ gemspec
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
- gem "bundler"
- gem "rake"
- gem "RedCloth", RUBY_PLATFORM == 'java' ? ">= 4.2.7" : ">= 4.0.3"
- gem "term-ansicolor"
- gem 'tins', '~> 1.6.0'
- gem "shoulda-context"
- gem "test-unit"
- gem "json" if RUBY_VERSION < '1.9'
- gem "rdoc"
+ gem 'bundler'
+ gem 'json', '~> 1.8' if RUBY_VERSION < '2.0'
+ gem 'rake', RUBY_VERSION < '1.9' ? '~> 10.5' : '>= 10.5'
+ gem 'rdoc', Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3') ? '~> 4.2.2' : Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2') ? '< 6' : '>= 6'
+ gem 'RedCloth', RUBY_PLATFORM == 'java' ? '= 4.2.9' : '>= 4.0.3'
+ gem 'rspec', '~> 3.9.0'
+ gem 'shoulda-context', RUBY_VERSION < '1.9' ? '= 1.2.1' : '>= 1.2.1'
+ gem 'simplecov', RUBY_VERSION < '2.7' ? '~> 0.17.1' : '>= 0.18.5'
+ gem 'term-ansicolor', RUBY_VERSION < '2.0' ? '~> 1.3.2' : '>= 1.3.2'
+ gem 'test-unit', RUBY_VERSION < '1.9' ? '~> 2.0' : '>= 3.0'
+ gem 'tins', RUBY_VERSION < '2.0' ? '~> 1.6.0' : '>= 1.6.0'
end
diff --git a/MIT-LICENSE.txt b/MIT-LICENSE
similarity index 87%
rename from MIT-LICENSE.txt
rename to MIT-LICENSE
index d8d009d1..9431e246 100644
--- a/MIT-LICENSE.txt
+++ b/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (C) 2005-2012 Kornelius Kalnbach (@murphy_karasu)
+Copyright (C) 2005 Kornelius Kalnbach (@murphy_karasu)
http://coderay.rubychan.de/
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.markdown b/README.markdown
index c3f71061..a768ef10 100644
--- a/README.markdown
+++ b/README.markdown
@@ -1,8 +1,6 @@
# CodeRay
-[](https://travis-ci.org/rubychan/coderay)
-[](https://badge.fury.io/rb/coderay)
-[](https://gemnasium.com/rubychan/coderay)
+[](https://dl.circleci.com/status-badge/redirect/gh/rubychan/coderay/tree/master) [](https://badge.fury.io/rb/coderay) [](https://codeclimate.com/github/rubychan/coderay/maintainability)
## About
diff --git a/bench/bench.rb b/bench/bench.rb
index 92f9d07f..a47721e3 100644
--- a/bench/bench.rb
+++ b/bench/bench.rb
@@ -15,7 +15,7 @@
format = ARGV.fetch(1, 'html').downcase
encoder = CodeRay.encoder(format)
-size = ARGV.fetch(2, 1000).to_i * 1000
+size = ARGV.fetch(2, 3000).to_i * 1000
unless size.zero?
data += data until data.size >= size
data = data[0, size]
@@ -23,14 +23,18 @@
size = data.size
puts "encoding %d kB of #{lang} code to #{format}..." % [(size / 1000.0).round]
-n = ARGV.fetch(3, 5).to_s[/\d+/].to_i
+n = ARGV.fetch(3, 10).to_s[/\d+/].to_i
require 'profile' if ARGV.include? '-p'
+times = []
n.times do |i|
time = Benchmark.realtime { encoder.encode(data, lang) }
puts "run %d: %5.2f s, %4.0f kB/s" % [i + 1, time, size / time / 1000.0]
+ times << time
end
-STDIN.gets if ARGV.include? '-w'
+times_sum = times.inject(0) { |time, sum| sum + time }
+puts 'Average time: %5.2f s, %4.0f kB/s' % [times_sum / times.size, (size * n) / times_sum / 1000.0]
+puts 'Best time: %5.2f s, %4.0f kB/s' % [times.min, size / times.min / 1000.0]
__END__
Usage:
diff --git a/coderay.gemspec b/coderay.gemspec
index 328b94c1..9aba34eb 100644
--- a/coderay.gemspec
+++ b/coderay.gemspec
@@ -24,12 +24,10 @@ Gem::Specification.new do |s|
readme_file = 'README_INDEX.rdoc'
- s.files = `git ls-files -- lib/* test/functional/* Rakefile #{readme_file} MIT-LICENSE`.split("\n")
- s.test_files = `git ls-files -- test/functional/*`.split("\n")
+ s.files = `git ls-files -- lib/* #{readme_file} MIT-LICENSE`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
s.require_paths = ['lib']
- s.rubyforge_project = s.name
- s.rdoc_options = '-SNw2', "-m#{readme_file}", '-t CodeRay Documentation'
+ s.rdoc_options = '-Nw2', "-m#{readme_file}", '-t CodeRay Documentation'
s.extra_rdoc_files = readme_file
end
diff --git a/lib/coderay/encoders/encoder.rb b/lib/coderay/encoders/encoder.rb
index fa5695d6..2baeedb6 100644
--- a/lib/coderay/encoders/encoder.rb
+++ b/lib/coderay/encoders/encoder.rb
@@ -146,7 +146,7 @@ def setup options
end
def get_output options
- options[:out] || ''
+ options[:out] || ''.dup
end
# Append data.to_s to the output. Returns the argument.
diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb
index 942b9c89..1b33e921 100644
--- a/lib/coderay/encoders/html.rb
+++ b/lib/coderay/encoders/html.rb
@@ -176,7 +176,7 @@ def setup options
if options[:wrap] || options[:line_numbers]
@real_out = @out
- @out = ''
+ @out = ''.dup
end
@break_lines = (options[:break_lines] == true)
@@ -314,7 +314,7 @@ def check_group_nesting name, kind
end
def break_lines text, style
- reopen = ''
+ reopen = ''.dup
@opened.each_with_index do |kind, index|
reopen << (@span_for_kinds[index > 0 ? [kind, *@opened[0...index]] : kind] || '')
end
diff --git a/lib/coderay/encoders/html/output.rb b/lib/coderay/encoders/html/output.rb
index de6f6ea1..ee87fea5 100644
--- a/lib/coderay/encoders/html/output.rb
+++ b/lib/coderay/encoders/html/output.rb
@@ -76,8 +76,6 @@ def wrap! element, *args
apply_title! title
end
self
- when nil
- return self
else
raise "Unknown value %p for :wrap" % element
end
diff --git a/lib/coderay/scanners/c.rb b/lib/coderay/scanners/c.rb
index 84b6e8ec..fb2f30db 100644
--- a/lib/coderay/scanners/c.rb
+++ b/lib/coderay/scanners/c.rb
@@ -37,7 +37,7 @@ class C < Scanner
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 e61f56f4..cd4d0941 100644
--- a/lib/coderay/scanners/cpp.rb
+++ b/lib/coderay/scanners/cpp.rb
@@ -2,14 +2,14 @@ module CodeRay
module Scanners
# Scanner for C++.
- #
+ #
# Aliases: +cplusplus+, c++
class CPlusPlus < Scanner
register_for :cpp
file_extension 'cpp'
title 'C++'
-
+
#-- http://www.cppreference.com/wiki/keywords/start
KEYWORDS = [
'and', 'and_eq', 'asm', 'bitand', 'bitor', 'break',
@@ -17,28 +17,30 @@ class CPlusPlus < Scanner
'continue', 'default', 'delete', 'do', 'dynamic_cast', 'else',
'enum', 'export', 'for', 'goto', 'if', 'namespace', 'new',
'not', 'not_eq', 'or', 'or_eq', 'reinterpret_cast', 'return',
- 'sizeof', 'static_cast', 'struct', 'switch', 'template',
- 'throw', 'try', 'typedef', 'typeid', 'typename', 'union',
+ 'sizeof', 'static_assert', 'static_cast', 'struct', 'switch',
+ 'template', 'throw', 'try', 'typedef', 'typeid', 'typename', 'union',
'while', 'xor', 'xor_eq',
] # :nodoc:
-
+
PREDEFINED_TYPES = [
- 'bool', 'char', 'double', 'float', 'int', 'long',
- 'short', 'signed', 'unsigned', 'wchar_t', 'string',
+ 'bool', 'char', 'char16_t', 'char32_t', 'double', 'float',
+ 'int', 'long', 'short', 'signed', 'unsigned',
+ 'wchar_t', 'string',
] # :nodoc:
PREDEFINED_CONSTANTS = [
'false', 'true',
- 'EOF', 'NULL',
+ 'EOF', 'NULL', 'nullptr'
] # :nodoc:
PREDEFINED_VARIABLES = [
'this',
] # :nodoc:
DIRECTIVES = [
- 'auto', 'const', 'explicit', 'extern', 'friend', 'inline', 'mutable', 'operator',
- 'private', 'protected', 'public', 'register', 'static', 'using', 'virtual', 'void',
- 'volatile',
+ 'alignas', 'alignof', 'auto', 'const', 'constexpr', 'decltype', 'explicit',
+ 'extern', 'final', 'friend', 'inline', 'mutable', 'noexcept', 'operator',
+ 'override', 'private', 'protected', 'public', 'register', 'static',
+ 'thread_local', 'using', 'virtual', 'void', 'volatile',
] # :nodoc:
-
+
IDENT_KIND = WordList.new(:ident).
add(KEYWORDS, :keyword).
add(PREDEFINED_TYPES, :predefined_type).
@@ -47,10 +49,10 @@ class CPlusPlus < Scanner
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
-
+
def scan_tokens encoder, options
state = :initial
@@ -107,7 +109,7 @@ def scan_tokens encoder, options
elsif match = scan(/\$/)
encoder.text_token match, :ident
-
+
elsif match = scan(/L?"/)
encoder.begin_group :string
if match[0] == ?L
@@ -180,7 +182,7 @@ def scan_tokens encoder, options
state = :initial
end
-
+
when :class_name_expected
if match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
encoder.text_token match, :class
@@ -194,7 +196,7 @@ def scan_tokens encoder, options
state = :initial
end
-
+
else
raise_inspect 'Unknown state', encoder
diff --git a/lib/coderay/scanners/diff.rb b/lib/coderay/scanners/diff.rb
index 74a6c27a..a2a6fccf 100644
--- a/lib/coderay/scanners/diff.rb
+++ b/lib/coderay/scanners/diff.rb
@@ -109,7 +109,7 @@ def scan_tokens encoder, options
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 @@ def diff a, b
# 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 c64454f0..c52ce8d3 100644
--- a/lib/coderay/scanners/groovy.rb
+++ b/lib/coderay/scanners/groovy.rb
@@ -22,8 +22,8 @@ class Groovy < Java
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/haml.rb b/lib/coderay/scanners/haml.rb
index 5433790a..d516ba9e 100644
--- a/lib/coderay/scanners/haml.rb
+++ b/lib/coderay/scanners/haml.rb
@@ -75,7 +75,7 @@ def scan_tokens encoder, options
tag = false
- if match = scan(/%[\w:]+\/?/)
+ if match = scan(/%[-\w:]+\/?/)
encoder.text_token match, :tag
# if match = scan(/( +)(.+)/)
# encoder.text_token self[1], :space
diff --git a/lib/coderay/scanners/java.rb b/lib/coderay/scanners/java.rb
index 962154eb..7dd1919e 100644
--- a/lib/coderay/scanners/java.rb
+++ b/lib/coderay/scanners/java.rb
@@ -20,7 +20,7 @@ class Java < Scanner
MAGIC_VARIABLES = %w[ this super ] # :nodoc:
TYPES = %w[
boolean byte char class double enum float int interface long
- short void
+ short void var
] << '[]' # :nodoc: because int[] should be highlighted as a type
DIRECTIVES = %w[
abstract extends final implements native private protected public
@@ -38,13 +38,13 @@ class Java < Scanner
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 = {
"'" => /[^\\']+/,
'"' => /[^\\"]+/,
'/' => /[^\\\/]+/,
} # :nodoc:
- IDENT = /[a-zA-Z_][A-Za-z_0-9]*/ # :nodoc:
+ IDENT = RUBY_VERSION < '1.9' ? /[a-zA-Z_][A-Za-z_0-9]*/ : Regexp.new('[[[:alpha:]]_][[[:alnum:]]_]*') # :nodoc:
protected
diff --git a/lib/coderay/scanners/java_script.rb b/lib/coderay/scanners/java_script.rb
index 9eb0a0a1..8c13d4ff 100644
--- a/lib/coderay/scanners/java_script.rb
+++ b/lib/coderay/scanners/java_script.rb
@@ -40,8 +40,8 @@ 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:
+ UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc:
+ REGEXP_ESCAPE = / [bBdDsSwW] /x # :nodoc:
STRING_CONTENT_PATTERN = {
"'" => /[^\\']+/,
'"' => /[^\\"]+/,
@@ -100,7 +100,6 @@ def scan_tokens encoder, options
# TODO: scan over nested tags
xml_scanner.tokenize match, :tokens => encoder
value_expected = false
- next
elsif match = scan(/ [-+*=<>?:;,!&^|(\[{~%]+ | \.(?!\d) /x)
value_expected = true
diff --git a/lib/coderay/scanners/lua.rb b/lib/coderay/scanners/lua.rb
index fb1e45a7..81d7dae4 100644
--- a/lib/coderay/scanners/lua.rb
+++ b/lib/coderay/scanners/lua.rb
@@ -76,7 +76,7 @@ def scan_tokens(encoder, options)
encoder.text_token(match, :comment)
elsif match = scan(/\[=*\[/) # [[ long (possibly multiline) string ]]
- num_equals = match.count("=") # Number must match for comment end
+ num_equals = match.count("=") # Number must match for string end
encoder.begin_group(:string)
encoder.text_token(match, :delimiter)
state = :long_string
diff --git a/lib/coderay/scanners/python.rb b/lib/coderay/scanners/python.rb
index 09c8b6e7..5da553a6 100644
--- a/lib/coderay/scanners/python.rb
+++ b/lib/coderay/scanners/python.rb
@@ -63,7 +63,7 @@ class Python < Scanner
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 e5a156d8..cd942d0d 100644
--- a/lib/coderay/scanners/ruby/patterns.rb
+++ b/lib/coderay/scanners/ruby/patterns.rb
@@ -60,7 +60,7 @@ module Ruby::Patterns # :nodoc: all
QUOTE_TO_TYPE = {
'`' => :shell,
- '/'=> :regexp,
+ '/' => :regexp,
}
QUOTE_TO_TYPE.default = :string
diff --git a/lib/coderay/scanners/sql.rb b/lib/coderay/scanners/sql.rb
index 7d57f773..c8725a8f 100644
--- a/lib/coderay/scanners/sql.rb
+++ b/lib/coderay/scanners/sql.rb
@@ -29,7 +29,7 @@ class SQL < Scanner
char varchar varchar2 enum binary text tinytext mediumtext
longtext blob tinyblob mediumblob longblob timestamp
date time datetime year double decimal float int
- integer tinyint mediumint bigint smallint unsigned bit
+ integer tinyint mediumint bigint smallint unsigned bit numeric
bool boolean hex bin oct
)
diff --git a/lib/coderay/token_kinds.rb b/lib/coderay/token_kinds.rb
old mode 100755
new mode 100644
diff --git a/lib/coderay/tokens.rb b/lib/coderay/tokens.rb
index e7bffce2..b5f78e71 100644
--- a/lib/coderay/tokens.rb
+++ b/lib/coderay/tokens.rb
@@ -39,6 +39,9 @@ module CodeRay
# You can serialize it to a JSON string and store it in a database, pass it
# around to encode it more than once, send it to other algorithms...
class Tokens < Array
+ # Remove Array#filter that is a new alias for Array#select on Ruby 2.6,
+ # for method_missing called with filter method.
+ undef_method :filter if instance_methods.include?(:filter)
# The Scanner instance that created the tokens.
attr_accessor :scanner
diff --git a/lib/coderay/version.rb b/lib/coderay/version.rb
index 7ea3f70c..3c68bd83 100644
--- a/lib/coderay/version.rb
+++ b/lib/coderay/version.rb
@@ -1,3 +1,3 @@
module CodeRay
- VERSION = '1.1.1'
+ VERSION = '1.1.3'
end
diff --git a/rake_tasks/benchmark.rake b/rake_tasks/benchmark.rake
index 2e38b577..8edeffb0 100644
--- a/rake_tasks/benchmark.rake
+++ b/rake_tasks/benchmark.rake
@@ -1,6 +1,6 @@
desc 'Do a benchmark'
task :benchmark do
- ruby 'bench/bench.rb ruby html 3000'
+ ruby 'bench/bench.rb ruby html'
end
task :bench => :benchmark
diff --git a/rake_tasks/code_statistics.rb b/rake_tasks/code_statistics.rb
index 0a2016bd..32eb3f06 100644
--- a/rake_tasks/code_statistics.rb
+++ b/rake_tasks/code_statistics.rb
@@ -156,7 +156,7 @@ def print_code_test_stats
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/rake_tasks/test.rake b/rake_tasks/test.rake
index b15b9993..e72c96b2 100644
--- a/rake_tasks/test.rake
+++ b/rake_tasks/test.rake
@@ -2,7 +2,7 @@ namespace :test do
desc 'run functional tests'
task :functional do
ruby './test/functional/suite.rb'
- ruby './test/functional/for_redcloth.rb'
+ ruby './test/functional/for_redcloth.rb' unless (''.chop! rescue true)
end
desc 'run unit tests'
@@ -37,7 +37,7 @@ Please rename or remove it and run again to use the GitHub repository:
else
puts 'Downloading scanner test suite...'
sh 'git clone https://github.com/rubychan/coderay-scanner-tests.git test/scanners/'
- end
+ end unless ENV['SKIP_UPDATE_SCANNER_SUITE']
end
namespace :scanner do
@@ -79,4 +79,9 @@ Please rename or remove it and run again to use the GitHub repository:
end
end
-task :test => %w(test:functional test:units test:exe)
+if RUBY_VERSION >= '1.9'
+ require 'rspec/core/rake_task'
+ RSpec::Core::RakeTask.new(:spec)
+end
+
+task :test => %w(test:functional test:units test:exe spec)
diff --git a/spec/coderay_spec.rb b/spec/coderay_spec.rb
new file mode 100644
index 00000000..88c9aece
--- /dev/null
+++ b/spec/coderay_spec.rb
@@ -0,0 +1,35 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+RSpec.describe CodeRay do
+ describe '::VERSION' do
+ it "returns the Gem's version" do
+ expect(CodeRay::VERSION).to match(/\A\d\.\d\.\d?\z/)
+ end
+ end
+
+ describe '.coderay_path' do
+ it 'returns an absolute file path to the given code file' do
+ base = File.expand_path('../..', __FILE__)
+ expect(CodeRay.coderay_path('file')).to eq("#{base}/lib/coderay/file")
+ end
+ end
+
+ describe '.scan' do
+ let(:code) { 'puts "Hello, World!"' }
+ let(:tokens) do
+ [
+ ['puts', :ident],
+ [' ', :space],
+ [:begin_group, :string],
+ ['"', :delimiter],
+ ['Hello, World!', :content],
+ ['"', :delimiter],
+ [:end_group, :string]
+ ].flatten
+ end
+
+ it 'returns tokens' do
+ expect(CodeRay.scan(code, :ruby).tokens).to eq(tokens)
+ end
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 00000000..4e2dac6e
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,105 @@
+require 'simplecov'
+
+# This file was generated by the `rspec --init` command. Conventionally, all
+# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
+# The generated `.rspec` file contains `--require spec_helper` which will cause
+# this file to always be loaded, without a need to explicitly require it in any
+# files.
+#
+# Given that it is always loaded, you are encouraged to keep this file as
+# light-weight as possible. Requiring heavyweight dependencies from this file
+# will add to the boot time of your test suite on EVERY test run, even for an
+# individual file that may not need all of that loaded. Instead, consider making
+# a separate helper file that requires the additional dependencies and performs
+# the additional setup, and require it from the spec files that actually need
+# it.
+#
+# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
+RSpec.configure do |config|
+ # rspec-expectations config goes here. You can use an alternate
+ # assertion/expectation library such as wrong or the stdlib/minitest
+ # assertions if you prefer.
+ config.expect_with :rspec do |expectations|
+ # This option will default to `true` in RSpec 4. It makes the `description`
+ # and `failure_message` of custom matchers include text for helper methods
+ # defined using `chain`, e.g.:
+ # be_bigger_than(2).and_smaller_than(4).description
+ # # => "be bigger than 2 and smaller than 4"
+ # ...rather than:
+ # # => "be bigger than 2"
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
+ end if RUBY_VERSION >= '1.9'
+
+ # rspec-mocks config goes here. You can use an alternate test double
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
+ config.mock_with :rspec do |mocks|
+ # Prevents you from mocking or stubbing a method that does not exist on
+ # a real object. This is generally recommended, and will default to
+ # `true` in RSpec 4.
+ mocks.verify_partial_doubles = true
+ end
+
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
+ # have no way to turn it off -- the option exists only for backwards
+ # compatibility in RSpec 3). It causes shared context metadata to be
+ # inherited by the metadata hash of host groups and examples, rather than
+ # triggering implicit auto-inclusion in groups with matching metadata.
+ config.shared_context_metadata_behavior = :apply_to_host_groups
+
+# The settings below are suggested to provide a good initial experience
+# with RSpec, but feel free to customize to your heart's content.
+=begin
+ # This allows you to limit a spec run to individual examples or groups
+ # you care about by tagging them with `:focus` metadata. When nothing
+ # is tagged with `:focus`, all examples get run. RSpec also provides
+ # aliases for `it`, `describe`, and `context` that include `:focus`
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
+ config.filter_run_when_matching :focus
+
+ # Allows RSpec to persist some state between runs in order to support
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
+ # you configure your source control system to ignore this file.
+ config.example_status_persistence_file_path = "spec/examples.txt"
+
+ # Limits the available syntax to the non-monkey patched syntax that is
+ # recommended. For more details, see:
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
+ config.disable_monkey_patching!
+
+ # This setting enables warnings. It's recommended, but in some cases may
+ # be too noisy due to issues in dependencies.
+ config.warnings = true
+
+ # Many RSpec users commonly either run the entire suite or an individual
+ # file, and it's useful to allow more verbose output when running an
+ # individual spec file.
+ if config.files_to_run.one?
+ # Use the documentation formatter for detailed output,
+ # unless a formatter has already been configured
+ # (e.g. via a command-line flag).
+ config.default_formatter = "doc"
+ end
+
+ # Print the 10 slowest examples and example groups at the
+ # end of the spec run, to help surface which specs are running
+ # particularly slow.
+ config.profile_examples = 10
+
+ # Run specs in random order to surface order dependencies. If you find an
+ # order dependency and want to debug it, you can fix the order by providing
+ # the seed, which is printed after each run.
+ # --seed 1234
+ config.order = :random
+
+ # Seed global randomization in this process using the `--seed` CLI option.
+ # Setting this allows you to use `--seed` to deterministically reproduce
+ # test failures related to randomization by passing the same `--seed` value
+ # as the one that triggered the failure.
+ Kernel.srand config.seed
+=end
+end
+
+$:.unshift File.expand_path('../lib', __FILE__)
+require 'coderay'
diff --git a/test/executable/suite.rb b/test/executable/suite.rb
index 997405ca..a6f40972 100644
--- a/test/executable/suite.rb
+++ b/test/executable/suite.rb
@@ -1,3 +1,4 @@
+require 'simplecov' if RUBY_VERSION >= '1.9'
require 'test/unit'
require 'rubygems' unless defined? Gem
require 'shoulda-context'
diff --git a/test/functional/basic.rb b/test/functional/basic.rb
old mode 100755
new mode 100644
index 752d4ba0..059d56c3
--- a/test/functional/basic.rb
+++ b/test/functional/basic.rb
@@ -97,7 +97,7 @@ def test_comment_filter
code
more code
- EXPECTED
+ EXPECTED
#!/usr/bin/env ruby
=begin
A multi-line comment.
@@ -105,7 +105,7 @@ def test_comment_filter
code
# A single-line comment.
more code # and another comment, in-line.
- INPUT
+ INPUT
end
def test_lines_of_code
@@ -117,7 +117,7 @@ def test_lines_of_code
code
# A single-line comment.
more code # and another comment, in-line.
- INPUT
+ INPUT
rHTML = <<-RHTML
@@ -138,7 +138,7 @@ def test_lines_of_code