Skip to content

Commit 78ed79f

Browse files
committed
Merge pull request rubocop#2225 from rrosenblum/performance_tweaks_phase_3
Performance tweaks phase 3
2 parents 910d5c0 + f96bfdc commit 78ed79f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

lib/rubocop/config.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ def file_to_exclude?(file)
151151
end
152152

153153
def patterns_to_include
154-
self['AllCops']['Include']
154+
@patterns_to_include ||= self['AllCops']['Include']
155155
end
156156

157157
def patterns_to_exclude
158-
self['AllCops']['Exclude']
158+
@patterns_to_exclude ||= self['AllCops']['Exclude']
159159
end
160160

161161
def path_relative_to_config(path)

lib/rubocop/formatter/progress_formatter.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ module Formatter
88
class ProgressFormatter < ClangStyleFormatter
99
include TextUtil
1010

11+
DOT = '.'.freeze
12+
GREEN_DOT = Rainbow(DOT).green.freeze
13+
14+
def initialize(output)
15+
super
16+
@dot = @output.tty? ? GREEN_DOT : DOT
17+
end
18+
1119
def started(target_files)
1220
super
1321
@offenses_for_files = {}
@@ -36,14 +44,14 @@ def finished(inspected_files)
3644
end
3745
end
3846

39-
report_summary(inspected_files.count,
47+
report_summary(inspected_files.size,
4048
@total_offense_count,
4149
@total_correction_count)
4250
end
4351

4452
def report_file_as_mark(offenses)
4553
mark = if offenses.empty?
46-
green('.')
54+
@dot
4755
else
4856
highest_offense = offenses.max_by(&:severity)
4957
colored_severity_code(highest_offense)

lib/rubocop/processed_source.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def disabled_line_ranges
4444
def lines
4545
@lines ||= begin
4646
all_lines = raw_source.lines.map(&:chomp)
47-
last_token_line = tokens.any? ? tokens.last.pos.line : all_lines.count
47+
last_token_line = tokens.any? ? tokens.last.pos.line : all_lines.size
4848
result = []
4949
all_lines.each_with_index do |line, ix|
5050
break if ix >= last_token_line && line == '__END__'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy