Skip to content

Commit 97b9885

Browse files
authored
resolves #213 set up Rubocop (#221)
1 parent 7f63e2f commit 97b9885

File tree

8 files changed

+181
-138
lines changed

8 files changed

+181
-138
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ on:
55
tags-ignore: [ '**' ]
66
pull_request:
77
jobs:
8+
rubocop:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
- name: Set up Ruby
14+
uses: ruby/setup-ruby@v1
15+
with:
16+
ruby-version: '3.0'
17+
bundler-cache: true
18+
- name: Rubocop
19+
run: bundle exec rubocop
820
build:
921
strategy:
1022
matrix:

.rubocop.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Metrics/AbcSize:
2+
Enabled: false
3+
Metrics/BlockLength:
4+
Enabled: false
5+
Metrics/ClassLength:
6+
Enabled: false
7+
Metrics/CyclomaticComplexity:
8+
Enabled: false
9+
Layout/LineLength:
10+
Max: 120
11+
Metrics/MethodLength:
12+
Enabled: false
13+
Security/MarshalLoad:
14+
Enabled: false
15+
Style/StructInheritance:
16+
Enabled: false
17+
Style/Documentation:
18+
Enabled: false

Rakefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ task default: :test
99
# Packaging
1010
# ==========================================================
1111

12-
GEMSPEC = eval(File.read('pygments.rb.gemspec'))
13-
1412
require 'rubygems/package_task'
1513

1614
# ==========================================================
@@ -36,7 +34,7 @@ end
3634

3735
# Write all the lexers to a file for easy lookup
3836
task :lexers do
39-
sh 'ruby cache-lexers.rb'
37+
sh 'ruby cache_lexers.rb'
4038
end
4139

4240
task(:test).enhance([:lexers])

bench.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require File.join(File.dirname(__FILE__), '/lib/pygments.rb')
44
require 'benchmark'
55

6-
include Benchmark
76
# number of iterations
87
num = ARGV[0] ? ARGV[0].to_i : 10
98

@@ -17,7 +16,13 @@
1716
puts 'Iterations: ' + num.to_s + "\n"
1817

1918
Benchmark.bm(40) do |x|
20-
x.report('pygments popen ') { (1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); } }
21-
x.report('pygments popen (process already started) ') { (1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); } }
22-
x.report('pygments popen (process already started 2) ') { (1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); } }
19+
x.report('pygments popen ') do
20+
(1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); }
21+
end
22+
x.report('pygments popen (process already started) ') do
23+
(1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); }
24+
end
25+
x.report('pygments popen (process already started 2) ') do
26+
(1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); }
27+
end
2328
end
File renamed without changes.

lib/pygments/lexer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def self.create(hash)
3030
extnames = []
3131

3232
extname = File.extname(filename)
33-
if m = extname.match(/\[(.+)\]/)
33+
if (m = extname.match(/\[(.+)\]/))
3434
m[1].scan(/./).each do |s|
3535
extnames << extname.sub(m[0], s)
3636
end

0 commit comments

Comments
 (0)