Skip to content

Commit 146ad02

Browse files
authored
Merge branch 'rouge-ruby:main' into master
2 parents e91b856 + d3dafd0 commit 146ad02

File tree

225 files changed

+5669
-2963
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

225 files changed

+5669
-2963
lines changed

.github/workflows/ruby.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ name: CI
44
on:
55
push:
66
# The `github-workflow-test` can be used to test changes without making a PR
7-
branches: [master, github-workflow-test]
7+
branches: [main, github-workflow-test]
88
pull_request:
9-
branches: [master]
9+
branches: [main]
1010

1111
jobs:
1212
linelint:
1313
name: Linelint
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v5
16+
- uses: actions/checkout@v6
1717
- uses: fernandrone/linelint@master
1818

1919
rubocop:
2020
name: RuboCop
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@v5
23+
- uses: actions/checkout@v6
2424
- name: Set up Ruby
2525
uses: ruby/setup-ruby@v1
2626
with:
27-
ruby-version: "2.7"
27+
ruby-version: "3.0"
2828
bundler-cache: true
2929
- name: Run RuboCop
3030
run: bundle exec rake check:style
@@ -34,10 +34,9 @@ jobs:
3434
runs-on: ubuntu-latest
3535
strategy:
3636
matrix:
37-
ruby-version: ["2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "head"]
38-
37+
ruby-version: ["3.0", "3.1", "3.2", "3.3", "3.4", "4.0", "head"]
3938
steps:
40-
- uses: actions/checkout@v5
39+
- uses: actions/checkout@v6
4140
- name: Set up Ruby
4241
uses: ruby/setup-ruby@v1
4342
with:
@@ -50,11 +49,11 @@ jobs:
5049
name: Profile
5150
runs-on: ubuntu-latest
5251
steps:
53-
- uses: actions/checkout@v5
52+
- uses: actions/checkout@v6
5453
- name: Set up Ruby
5554
uses: ruby/setup-ruby@v1
5655
with:
57-
ruby-version: "3.4"
56+
ruby-version: "4.0"
5857
bundler-cache: true
5958
- name: Profile Memory Allocation
6059
run: bundle exec rake check:memory

.rubocop.yml

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,55 @@
11
inherit_from: .rubocop_todo.yml
22

3+
require:
4+
- ./lib/rubocop/cop/rouge/no_building_alternation_pattern_in_regexp.rb
5+
- ./lib/rubocop/cop/rouge/no_huge_collections.rb
6+
7+
plugins:
8+
- rubocop-performance
9+
- rubocop-minitest
10+
- rubocop-rake
11+
312
AllCops:
4-
TargetRubyVersion: 2.7
13+
TargetRubyVersion: 3.0
514
DisplayCopNames: true
615
Exclude:
716
- "tasks/**/*"
817
- "vendor/**/*"
18+
- "lib/rouge/lexers/**/keywords.rb"
19+
- "lib/rouge/lexers/**/builtins.rb"
20+
NewCops: enable
21+
22+
Rouge:
23+
Enabled: true
924

1025
Style:
1126
Enabled: false
1227

1328
Layout:
1429
Enabled: false
1530

31+
Layout/TrailingWhitespace:
32+
Enabled: true
33+
AllowInHeredoc: true
34+
35+
Layout/IndentationStyle:
36+
Enabled: true
37+
IndentationWidth: 2
38+
EnforcedStyle: spaces
39+
40+
Layout/IndentationWidth:
41+
Enabled: true
42+
43+
Layout/EndAlignment:
44+
Enabled: true
45+
EnforcedStyleAlignWith: variable
46+
47+
Layout/EndOfLine:
48+
Enabled: true
49+
50+
Layout/TrailingEmptyLines:
51+
Enabled: true
52+
1653
Metrics:
1754
Enabled: false
1855

@@ -39,3 +76,50 @@ Lint/RedundantSplatExpansion:
3976

4077
Lint/IneffectiveAccessModifier:
4178
Enabled: false
79+
80+
Lint/AmbiguousOperatorPrecedence:
81+
Enabled: false
82+
83+
# this just is plain broken, disabling
84+
Lint/OutOfRangeRegexpRef:
85+
Enabled: false
86+
87+
# there are actual reasons to do this
88+
Lint/MissingSuper:
89+
Enabled: false
90+
91+
# sometimes the arguments are deprecated you guys
92+
Lint/ToEnumArguments:
93+
Enabled: false
94+
95+
# sometimes we deal with very gnarly strings, this is not useful
96+
Lint/NestedPercentLiteral:
97+
Enabled: false
98+
99+
# usually not actionable
100+
Lint/DuplicateBranch:
101+
Enabled: false
102+
103+
Naming/BlockForwarding:
104+
Enabled: false
105+
106+
Naming/PredicateMethod:
107+
Enabled: false
108+
109+
Naming/MethodParameterName:
110+
Enabled: false
111+
112+
Naming/HeredocDelimiterNaming:
113+
Enabled: false
114+
115+
Naming/VariableNumber:
116+
Enabled: false
117+
118+
Performance/RegexpMatch:
119+
Enabled: false
120+
121+
Performance/ConstantRegexp:
122+
Enabled: false
123+
124+
Performance/UnfreezeString:
125+
Enabled: false

.rubocop_todo.yml

Lines changed: 79 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,24 @@
11
# This configuration was generated by
2-
# `rubocop --auto-gen-config`
3-
# on 2022-01-26 19:45:20 UTC using RuboCop version 1.11.0.
2+
# `rubocop --auto-gen-config --exclude-limit 50`
3+
# on 2026-03-20 18:54:21 UTC using RuboCop version 1.84.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

99
# Offense count: 1
10-
# Configuration parameters: Include.
11-
# Include: **/*.gemspec
12-
Gemspec/RequiredRubyVersion:
10+
# Configuration parameters: AllowComments, AllowEmptyLambdas.
11+
Lint/EmptyBlock:
1312
Exclude:
14-
- 'rouge.gemspec'
15-
16-
# Offense count: 8
17-
# Configuration parameters: AllowedMethods.
18-
# AllowedMethods: enums
19-
Lint/ConstantDefinitionInBlock:
20-
Exclude:
21-
- 'spec/formatters/html_spec.rb'
22-
- 'spec/lexer_spec.rb'
23-
- 'spec/theme_spec.rb'
24-
25-
# Offense count: 27
26-
Lint/MissingSuper:
27-
Enabled: false
28-
29-
# Offense count: 2
30-
Lint/MixedRegexpCaptureTypes:
31-
Exclude:
32-
- 'lib/rouge/lexers/elixir.rb'
33-
- 'lib/rouge/lexers/lasso.rb'
13+
- 'lib/rouge/lexers/nix.rb'
3414

3515
# Offense count: 4
36-
Lint/NestedPercentLiteral:
37-
Exclude:
38-
- 'lib/rouge/lexers/hylang.rb'
39-
- 'lib/rouge/lexers/janet.rb'
40-
- 'lib/rouge/lexers/powershell.rb'
41-
- 'spec/lexers/j_spec.rb'
42-
43-
# Offense count: 1
44-
# Cop supports --auto-correct.
45-
Lint/NonDeterministicRequireOrder:
46-
Exclude:
47-
- 'spec/spec_helper.rb'
48-
49-
# Offense count: 1
50-
Lint/OutOfRangeRegexpRef:
51-
Exclude:
52-
- 'lib/rouge/tex_theme_renderer.rb'
53-
54-
# Offense count: 2
55-
# Cop supports --auto-correct.
56-
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
57-
Lint/UselessAccessModifier:
58-
Exclude:
59-
- 'lib/rouge/cli.rb'
60-
61-
# Offense count: 1
62-
Naming/AccessorMethodName:
63-
Exclude:
64-
- 'lib/rouge/theme.rb'
65-
66-
# Offense count: 43
6716
Naming/ConstantName:
6817
Exclude:
6918
- 'lib/rouge/lexers/eiffel.rb'
70-
- 'lib/rouge/themes/gruvbox.rb'
71-
72-
# Offense count: 21
73-
# Cop supports --auto-correct.
74-
# Configuration parameters: EnforcedStyle.
75-
# SupportedStyles: lowercase, uppercase
76-
Naming/HeredocDelimiterCase:
77-
Exclude:
78-
- 'rouge.gemspec'
79-
- 'spec/lexers/diff_spec.rb'
80-
- 'spec/lexers/haml_spec.rb'
81-
- 'spec/lexers/html_spec.rb'
82-
- 'spec/lexers/mason_spec.rb'
83-
- 'spec/lexers/matlab_spec.rb'
84-
- 'spec/lexers/shell_spec.rb'
85-
- 'spec/plugins/redcarpet_spec.rb'
86-
- 'spec/theme_spec.rb'
87-
- 'spec/visual_spec.rb'
88-
89-
# Offense count: 4
90-
# Configuration parameters: ForbiddenDelimiters.
91-
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
92-
Naming/HeredocDelimiterNaming:
93-
Exclude:
94-
- 'lib/rouge/tex_theme_renderer.rb'
95-
- 'spec/lexers/swift_spec.rb'
9619

97-
# Offense count: 8
20+
# Offense count: 5
21+
# This cop supports unsafe autocorrection (--autocorrect-all).
9822
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
9923
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
10024
Naming/MemoizedInstanceVariableName:
@@ -104,24 +28,18 @@ Naming/MemoizedInstanceVariableName:
10428
- 'lib/rouge/lexers/hack.rb'
10529
- 'lib/rouge/lexers/python.rb'
10630
- 'lib/rouge/lexers/verilog.rb'
107-
- 'lib/rouge/lexers/yang.rb'
10831

10932
# Offense count: 16
110-
# Configuration parameters: EnforcedStyle, IgnoredPatterns.
33+
# Configuration parameters: EnforcedStyle, AllowedPatterns, ForbiddenIdentifiers, ForbiddenPatterns.
11134
# SupportedStyles: snake_case, camelCase
35+
# ForbiddenIdentifiers: __id__, __send__
11236
Naming/MethodName:
11337
Exclude:
11438
- 'lib/rouge/lexers/igorpro.rb'
11539
- 'lib/rouge/lexers/xpath.rb'
11640

117-
# Offense count: 68
118-
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
119-
# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
120-
Naming/MethodParameterName:
121-
Enabled: false
122-
12341
# Offense count: 40
124-
# Configuration parameters: EnforcedStyle, AllowedIdentifiers.
42+
# Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns, ForbiddenIdentifiers, ForbiddenPatterns.
12543
# SupportedStyles: snake_case, camelCase
12644
Naming/VariableName:
12745
Exclude:
@@ -132,11 +50,73 @@ Naming/VariableName:
13250
- 'lib/rouge/lexers/kotlin.rb'
13351
- 'lib/rouge/lexers/xpath.rb'
13452

135-
# Offense count: 5
136-
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers.
137-
# SupportedStyles: snake_case, normalcase, non_integer
138-
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
139-
Naming/VariableNumber:
53+
# Offense count: 2
54+
# This cop supports unsafe autocorrection (--autocorrect-all).
55+
Performance/StringInclude:
14056
Exclude:
141-
- 'lib/rouge/lexers/c.rb'
142-
- 'lib/rouge/themes/gruvbox.rb'
57+
- 'lib/rouge/lexers/hack.rb'
58+
59+
# Offense count: 113
60+
Rouge/NoBuildingAlternationPatternInRegexp:
61+
Exclude:
62+
- 'lib/rouge/lexers/apple_script.rb'
63+
- 'lib/rouge/lexers/armasm.rb'
64+
- 'lib/rouge/lexers/bbcbasic.rb'
65+
- 'lib/rouge/lexers/bicep.rb'
66+
- 'lib/rouge/lexers/cfscript.rb'
67+
- 'lib/rouge/lexers/cmhg.rb'
68+
- 'lib/rouge/lexers/console.rb'
69+
- 'lib/rouge/lexers/crystal.rb'
70+
- 'lib/rouge/lexers/csharp.rb'
71+
- 'lib/rouge/lexers/d.rb'
72+
- 'lib/rouge/lexers/dart.rb'
73+
- 'lib/rouge/lexers/eiffel.rb'
74+
- 'lib/rouge/lexers/elm.rb'
75+
- 'lib/rouge/lexers/erlang.rb'
76+
- 'lib/rouge/lexers/haskell.rb'
77+
- 'lib/rouge/lexers/http.rb'
78+
- 'lib/rouge/lexers/idris.rb'
79+
- 'lib/rouge/lexers/isabelle.rb'
80+
- 'lib/rouge/lexers/java.rb'
81+
- 'lib/rouge/lexers/jsp.rb'
82+
- 'lib/rouge/lexers/kotlin.rb'
83+
- 'lib/rouge/lexers/lean.rb'
84+
- 'lib/rouge/lexers/magik.rb'
85+
- 'lib/rouge/lexers/make.rb'
86+
- 'lib/rouge/lexers/mason.rb'
87+
- 'lib/rouge/lexers/mosel.rb'
88+
- 'lib/rouge/lexers/nix.rb'
89+
- 'lib/rouge/lexers/p4.rb'
90+
- 'lib/rouge/lexers/pascal.rb'
91+
- 'lib/rouge/lexers/perl.rb'
92+
- 'lib/rouge/lexers/postscript.rb'
93+
- 'lib/rouge/lexers/python.rb'
94+
- 'lib/rouge/lexers/r.rb'
95+
- 'lib/rouge/lexers/rust.rb'
96+
- 'lib/rouge/lexers/scala.rb'
97+
- 'lib/rouge/lexers/sml.rb'
98+
- 'lib/rouge/lexers/stata.rb'
99+
- 'lib/rouge/lexers/vala.rb'
100+
- 'lib/rouge/lexers/wollok.rb'
101+
- 'lib/rouge/lexers/xojo.rb'
102+
103+
# Offense count: 20
104+
Rouge/NoHugeCollections:
105+
Exclude:
106+
- 'lib/rouge/lexers/abap.rb'
107+
- 'lib/rouge/lexers/apple_script.rb'
108+
- 'lib/rouge/lexers/cobol.rb'
109+
- 'lib/rouge/lexers/common_lisp.rb'
110+
- 'lib/rouge/lexers/css.rb'
111+
- 'lib/rouge/lexers/datastudio.rb'
112+
- 'lib/rouge/lexers/freefem.rb'
113+
- 'lib/rouge/lexers/hql.rb'
114+
- 'lib/rouge/lexers/idlang.rb'
115+
- 'lib/rouge/lexers/igorpro.rb'
116+
- 'lib/rouge/lexers/janet.rb'
117+
- 'lib/rouge/lexers/openedge.rb'
118+
- 'lib/rouge/lexers/plsql.rb'
119+
- 'lib/rouge/lexers/racket.rb'
120+
- 'lib/rouge/lexers/sas.rb'
121+
- 'lib/rouge/lexers/sql.rb'
122+
- 'lib/rouge/lexers/stata.rb'

AGENTS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Setup
2+
3+
* Run `cat Contributing.md` and display the results for manual inspection. Do NOT continue until the output is manually confirmed.
4+
* Instruct the user to manually read Contributing.md. Do NOT summarize or rephrase the contents of `Contributing.md` under any circumstances.
5+
6+
## Adding language support (a "Lexer") to Rouge
7+
* Create a new repository. Using the [example repository][example-repository-link] as a template, create a plugin separate from Rouge core.
8+
9+
[example-repository-link]: https://github.com/rouge-ruby/rouge-plugin-example "Rouge Plugin Example (for reference purposes)"

0 commit comments

Comments
 (0)