punchlist 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3a91cd04e344a758a88d1892086339492be3306
4
- data.tar.gz: cea784b35403f68c784694e64101b342fc0328b5
3
+ metadata.gz: 417c0f1b1739e879b670660d5965b2de9983ebd6
4
+ data.tar.gz: cd161e7cbf434e7011cc6f6a52ca16fc9d2816aa
5
5
  SHA512:
6
- metadata.gz: c5327b956982854e55f5b4e620ab0060825cd39e70838cccb818490e9f48dca889ccbc7329b94c416c2fd0465b815caa15f1004718a526321992bad392319419
7
- data.tar.gz: c7663708ff7dc748f159db4adb607e6267334396551abe8d74d82eb53bcfdf1c43852e73d027d249953cce532d2a681d722bd25ac960b537b2b69d1139852392
6
+ metadata.gz: 634f25dc315d1b0f78b75924b824a5bf495d4214194d49bee2b3a04fe6de3e11afd61e4d19001dac3adabe458a6a0e05ecaf3329f44af87feff9daa2e3672fcc
7
+ data.tar.gz: bf6b12e411662a479591c668a661bd75ad1b712881085130a2bd5edb3d182681498695b92a3ea961bae3707fed05356e07c52e7b8c4ef5806694f07473328a44
data/Rakefile CHANGED
@@ -1,12 +1,32 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
  require 'quality/rake/task'
4
6
 
7
+ task :pronto do
8
+ formatter = '-f github_pr' if ENV.key? 'PRONTO_GITHUB_ACCESS_TOKEN'
9
+ if ENV.key? 'TRAVIS_PULL_REQUEST'
10
+ ENV['PRONTO_PULL_REQUEST_ID'] = ENV['TRAVIS_PULL_REQUEST']
11
+ elsif ENV.key? 'CIRCLE_PULL_REQUEST'
12
+ ENV['PRONTO_PULL_REQUEST_ID'] = ENV['CIRCLE_PULL_REQUEST'].split('/').last
13
+ end
14
+ puts "PRONTO_PULL_REQUEST_ID is #{ENV['PRONTO_PULL_REQUEST_ID']}"
15
+ sh "pronto run #{formatter} -c origin/master --no-exit-code --unstaged "\
16
+ '|| true'
17
+ sh "pronto run #{formatter} -c origin/master --no-exit-code --staged || true"
18
+ sh "pronto run #{formatter} -c origin/master --no-exit-code || true"
19
+ end
20
+
5
21
  Quality::Rake::Task.new do |task|
6
- task.skip_tools = ['reek']
22
+ task.skip_tools = %w[reek shellcheck]
7
23
  task.output_dir = 'metrics'
24
+ # Add 'xit ' to the standard list, finding disabled tests
25
+ task.punchlist_regexp = 'XXX|TODO|FIXME|OPTIMIZE|HACK|REVIEW|LATER|FIXIT|xit '
8
26
  end
9
27
 
28
+ task quality: %i[pronto]
29
+
10
30
  desc 'Run specs'
11
31
  RSpec::Core::RakeTask.new(:spec) do |task|
12
32
  task.pattern = 'spec/**/*_spec.rb'
@@ -22,9 +42,10 @@ end
22
42
  task :clear_metrics do |_t|
23
43
  ret =
24
44
  system('git checkout coverage/.last_run.json metrics/*_high_water_mark')
25
- fail unless ret
45
+ raise unless ret
26
46
  end
27
47
 
28
48
  desc 'Default: Run specs and check quality.'
29
- task localtest: [:clear_metrics, :spec, :feature, :quality]
49
+ task localtest: %i[clear_metrics spec feature quality]
50
+ task test: %i[spec feature]
30
51
  task default: [:localtest]
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require_relative '../lib/punchlist'
4
5
 
@@ -1,26 +1,24 @@
1
- require_relative 'punchlist/options'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'punchlist/option_parser'
4
+ require_relative 'punchlist/inspector'
5
+ require_relative 'punchlist/renderer'
2
6
 
3
7
  # XXX: need to include BUG in list
4
8
  # XXX: need to include BUG in my rubocop config
5
- # BUG need to fix the fact that we create blank lines on files with no issues
6
9
  module Punchlist
7
10
  # Counts the number of 'todo' comments in your code.
8
11
  class Punchlist
9
12
  def initialize(args,
10
13
  outputter: STDOUT,
11
- file_opener: File,
12
- options_parser: Options.new(args),
14
+ option_parser_class: OptionParser,
13
15
  source_file_globber: SourceFinder::SourceFileGlobber.new)
14
- @args = args
16
+ option_parser = option_parser_class.new(args)
17
+ @config = option_parser.generate_config(source_file_globber)
15
18
  @outputter = outputter
16
- @file_opener = file_opener
17
- @options_parser = options_parser
18
- @source_file_globber = source_file_globber
19
19
  end
20
20
 
21
21
  def run
22
- @options = @options_parser.parse_options
23
-
24
22
  analyze_files
25
23
 
26
24
  0
@@ -28,50 +26,18 @@ module Punchlist
28
26
 
29
27
  def analyze_files
30
28
  all_output = []
31
- source_files.each do |filename|
29
+ @config.source_files.each do |filename|
32
30
  all_output.concat(look_for_punchlist_items(filename))
33
31
  end
34
32
  @outputter.print render(all_output)
35
33
  end
36
34
 
37
- def source_files
38
- if @options[:glob]
39
- @source_file_globber.source_files_glob = @options[:glob]
40
- end
41
- if @options[:exclude]
42
- @source_file_globber.source_files_exclude_glob = @options[:exclude]
43
- end
44
- @source_file_globber.source_files_arr
45
- end
46
-
47
- def punchlist_line_regexp
48
- return @regexp if @regexp
49
-
50
- regexp_string = @options[:regexp]
51
- if regexp_string
52
- @regexp = Regexp.new(regexp_string)
53
- else
54
- Options.default_punchlist_line_regexp
55
- end
56
- end
57
-
58
35
  def look_for_punchlist_items(filename)
59
- lines = []
60
- line_num = 0
61
- @file_opener.open(filename, 'r') do |file|
62
- file.each_line do |line|
63
- line_num += 1
64
- lines << [filename, line_num, line] if line =~ punchlist_line_regexp
65
- end
66
- end
67
- lines
36
+ Inspector.new(@config.regexp, filename).run
68
37
  end
69
38
 
70
39
  def render(output)
71
- lines = output.map do |filename, line_num, line|
72
- "#{filename}:#{line_num}: #{line}"
73
- end
74
- lines.join
40
+ CliRenderer.new.render(output)
75
41
  end
76
42
  end
77
43
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Punchlist
4
+ # Configuration for punchlist gem
5
+ class Config
6
+ attr_reader :regexp, :glob, :exclude
7
+
8
+ def self.default_punchlist_line_regexp_string
9
+ 'XXX|TODO|FIXME|OPTIMIZE|HACK|REVIEW|LATER|FIXIT'
10
+ end
11
+
12
+ def source_files
13
+ @source_file_globber.source_files_glob = glob if glob
14
+ @source_file_globber.source_files_exclude_glob = exclude if exclude
15
+ @source_file_globber.source_files_arr
16
+ end
17
+
18
+ def initialize(regexp: nil, glob: nil, exclude: nil,
19
+ source_file_globber:)
20
+ @regexp = Regexp.new(regexp ||
21
+ Config.default_punchlist_line_regexp_string)
22
+ @glob = glob
23
+ @exclude = exclude
24
+ @source_file_globber = source_file_globber
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'offense'
4
+
5
+ module Punchlist
6
+ # Inspects files for punchlist items
7
+ class Inspector
8
+ attr_reader :punchlist_line_regexp, :filename
9
+ def initialize(punchlist_line_regexp, filename, file_opener: File)
10
+ @file_opener = file_opener
11
+ @punchlist_line_regexp = punchlist_line_regexp
12
+ @filename = filename
13
+ @lines = []
14
+ @line_num = 0
15
+ end
16
+
17
+ def inspect_line(line)
18
+ @line_num += 1
19
+ return unless line =~ punchlist_line_regexp
20
+
21
+ @lines << Offense.new(filename, @line_num, line.chomp)
22
+ end
23
+
24
+ def run
25
+ @file_opener.open(filename, 'r') do |file|
26
+ file.each_line { |line| inspect_line(line) }
27
+ end
28
+ @lines
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Punchlist
4
+ # Represents a discovered punchlist item in code
5
+ class Offense
6
+ attr_reader :filename, :line_num, :line
7
+ def initialize(filename, line_num, line)
8
+ @filename = filename
9
+ @line_num = line_num
10
+ @line = line
11
+ end
12
+
13
+ def ==(other)
14
+ other.class == self.class && other.state == state
15
+ end
16
+
17
+ protected
18
+
19
+ def state
20
+ [@filename, @line_num, @line]
21
+ end
22
+ end
23
+ end
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'optparse'
2
4
  require 'source_finder/option_parser'
5
+ require_relative 'config'
3
6
 
4
7
  module Punchlist
5
8
  # Parse command line options
6
- class Options
9
+ class OptionParser
7
10
  attr_reader :default_punchlist_line_regexp
8
11
 
9
12
  def initialize(args,
@@ -12,18 +15,10 @@ module Punchlist
12
15
  @source_finder_option_parser = source_finder_option_parser
13
16
  end
14
17
 
15
- def self.default_punchlist_line_regexp_string
16
- 'XXX|TODO|FIXME|OPTIMIZE|HACK|REVIEW|LATER|FIXIT'
17
- end
18
-
19
- def self.default_punchlist_line_regexp
20
- Regexp.new(default_punchlist_line_regexp_string)
21
- end
22
-
23
18
  def parse_regexp(opts, options)
24
19
  opts.on('-r', '--regexp r',
25
- 'Regexp to trigger opon - default is ' \
26
- "#{self.class.default_punchlist_line_regexp_string}") do |v|
20
+ 'Regexp to trigger upon - default is ' \
21
+ "#{Config.default_punchlist_line_regexp_string}") do |v|
27
22
  options[:regexp] = v
28
23
  end
29
24
  end
@@ -36,12 +31,12 @@ module Punchlist
36
31
  options
37
32
  end
38
33
 
39
- def parse_options
34
+ def generate_config(source_file_globber)
40
35
  options = nil
41
- OptionParser.new do |opts|
36
+ ::OptionParser.new do |opts|
42
37
  options = setup_options(opts)
43
38
  end.parse!(@args)
44
- options
39
+ Config.new(**options, source_file_globber: source_file_globber)
45
40
  end
46
41
  end
47
42
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Punchlist
4
+ # Render a text format of offenses
5
+ class CliRenderer
6
+ def render(output)
7
+ lines = output.map do |offense|
8
+ "#{offense.filename}:#{offense.line_num}: #{offense.line}"
9
+ end
10
+ out = lines.join("\n")
11
+ if out.empty?
12
+ out
13
+ else
14
+ out + "\n"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Counts the number of 'todo' comments in your code ('Comment
2
4
  # annotations').
3
5
  module Punchlist
4
- VERSION = '1.2.0'
6
+ VERSION = '1.3.0'
5
7
  end
@@ -1,5 +1,6 @@
1
1
  # ; -*-Ruby-*-
2
- # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
3
4
  $LOAD_PATH.push File.join(File.dirname(__FILE__), 'lib')
4
5
  require 'punchlist/version'
5
6
 
@@ -29,8 +30,10 @@ Gem::Specification.new do |s|
29
30
  s.add_dependency('source_finder', ['>=2'])
30
31
 
31
32
  s.add_development_dependency('bundler')
33
+ s.add_development_dependency('pronto')
34
+ s.add_development_dependency('pronto-rubocop')
35
+ s.add_development_dependency('quality', ['~> 36'])
32
36
  s.add_development_dependency('rake')
33
- s.add_development_dependency('quality', ['>=16'])
34
37
  s.add_development_dependency('rspec')
35
38
  s.add_development_dependency('simplecov')
36
39
  end
metadata CHANGED
@@ -1,97 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: punchlist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-13 00:00:00.000000000 Z
11
+ date: 2019-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: source_finder
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: pronto
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pronto-rubocop
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - '>='
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: quality
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '>='
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '16'
75
+ version: '36'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '>='
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '16'
82
+ version: '36'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rspec
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
- - - '>='
101
+ - - ">="
74
102
  - !ruby/object:Gem::Version
75
103
  version: '0'
76
104
  type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
- - - '>='
108
+ - - ">="
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: simplecov
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
- - - '>='
115
+ - - ">="
88
116
  - !ruby/object:Gem::Version
89
117
  version: '0'
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
- - - '>='
122
+ - - ">="
95
123
  - !ruby/object:Gem::Version
96
124
  version: '0'
97
125
  description: punchlist lists your annotation comments--things like 'LATER/HACK/FIXIT'
@@ -106,7 +134,11 @@ files:
106
134
  - Rakefile
107
135
  - bin/punchlist
108
136
  - lib/punchlist.rb
109
- - lib/punchlist/options.rb
137
+ - lib/punchlist/config.rb
138
+ - lib/punchlist/inspector.rb
139
+ - lib/punchlist/offense.rb
140
+ - lib/punchlist/option_parser.rb
141
+ - lib/punchlist/renderer.rb
110
142
  - lib/punchlist/version.rb
111
143
  - punchlist.gemspec
112
144
  homepage: http://github.com/apiology/punchlist
@@ -119,17 +151,17 @@ require_paths:
119
151
  - lib
120
152
  required_ruby_version: !ruby/object:Gem::Requirement
121
153
  requirements:
122
- - - '>='
154
+ - - ">="
123
155
  - !ruby/object:Gem::Version
124
156
  version: '0'
125
157
  required_rubygems_version: !ruby/object:Gem::Requirement
126
158
  requirements:
127
- - - '>='
159
+ - - ">="
128
160
  - !ruby/object:Gem::Version
129
161
  version: '0'
130
162
  requirements: []
131
163
  rubyforge_project:
132
- rubygems_version: 2.4.6
164
+ rubygems_version: 2.6.14.4
133
165
  signing_key:
134
166
  specification_version: 4
135
167
  summary: Finds largest source files in a project