rubocop-safe_todo_searcher 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b7a18ffdd32249f8ae28b6bc0390626068b80740aab32f5853d5a315fa57675
4
- data.tar.gz: 2459d8c1d8cd5ac0e3c296f0e887fce08f9a25aef10a8fda794349fafef895f9
3
+ metadata.gz: b6c84f35549d9f062edd505f84347f69b504393459c0ad1ade859f197e99c0fa
4
+ data.tar.gz: b8f299a87ea3a37d7bc7a18d13b0235f1e287066aef0e6ff915ce12e3a3359f4
5
5
  SHA512:
6
- metadata.gz: 416cc45b863ea5290f275abfd9d755ffc105812e35cb78cd26b26659c77f3f3ed7f679264e4a101491877806c8913ae113213e58a43bd9f5510026bfdd2dde83
7
- data.tar.gz: a1ea62866061ff6009f5962533c8046c32851ef134b87e91ebb5c47b52f06485f8fc8d77c93177d6742db96a486b2cd38d0aa74e29f24263cd4bdf283ca6f1f9
6
+ metadata.gz: 8e342c999d821c07e57f0c6e7eded6e2e403e784a2208954e11d67f6eb07df492f3175da0284f2bfca9b5af72a27740f0d98fbcd65643dfbe4990317fe40f19c
7
+ data.tar.gz: 958547a8d73b7bd79d9fc83a540d39639b9f9b1a3e8cf05f02c4ad0481df69b8509d7d83c78ea82eecef1f3e0960f6096c472da2bc735374f50231a28586f14a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.3] - 2022-02-19
4
+
5
+ ### New features:
6
+ - [#21](https://github.com/ydah/rubocop-safe_todo_searcher/pull/21) : Output logs to stdout to show that program is running when it is running.
7
+
8
+ ### Bug fixes
9
+ - [#18](https://github.com/ydah/rubocop-safe_todo_searcher/pull/18) : Fixes to detect cops that were not supported.
10
+ - [#19](https://github.com/ydah/rubocop-safe_todo_searcher/pull/19) : Fixes NoMethodError if none of keys are found in rubocop_todo.yml.
11
+
3
12
  ## [0.1.2] - 2022-01-07
4
13
 
5
14
  ### New features:
data/exe/safe-search CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "rubocop/safe_todo_searcher"
4
4
 
5
- puts Rubocop::SafeTodoSearcher.search
5
+ Rubocop::SafeTodoSearcher.search
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rubocop
4
4
  module SafeTodoSearcher
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
@@ -1,31 +1,70 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rubocop"
4
+ require "rubocop-minitest"
5
+ require "rubocop-performance"
4
6
  require "rubocop-rails"
7
+ require "rubocop-rake"
8
+ require "rubocop-rspec"
9
+ require "rubocop-sequel"
10
+ require "date"
11
+ require "highline"
5
12
  require "yaml"
6
13
  require_relative "safe_todo_searcher/version"
7
14
 
8
15
  module Rubocop
9
16
  module SafeTodoSearcher
10
- class Error < StandardError; end
17
+ RUBOCOP_TODO_YML = ".rubocop_todo.yml"
11
18
 
12
- def self.search
13
- File.exist?(".rubocop_todo.yml") ? parse : "rubocop_todo.yml does not exist"
14
- end
19
+ class << self
20
+ def search
21
+ puts generate_header
22
+ puts horizontal_line
23
+ puts generate_results
24
+ puts horizontal_line
25
+ end
15
26
 
16
- def self.parse
17
- res = +""
18
- File.open(".rubocop_todo.yml", "r") { |f| YAML.safe_load(f) }.each_key do |key|
19
- res << "#{key}\n" if support_autocorrect?(key)
27
+ private
28
+
29
+ def generate_results
30
+ File.exist?(RUBOCOP_TODO_YML) ? parse : "#{RUBOCOP_TODO_YML} does not exist"
31
+ end
32
+
33
+ def parse
34
+ res = +""
35
+ File.open(RUBOCOP_TODO_YML, "r") { |f| YAML.safe_load(f) }&.each_key do |key|
36
+ res << "#{key}\n" if support_autocorrect?(key)
37
+ end
38
+ res
39
+ end
40
+
41
+ def support_autocorrect?(key)
42
+ cop = Object.const_get "RuboCop::Cop::#{key.gsub(%r{/}, "::")}"
43
+ cop.support_autocorrect? && cop.new(RuboCop::ConfigLoader.default_configuration).safe_autocorrect?
44
+ rescue NameError
45
+ false
20
46
  end
21
- res
22
- end
23
47
 
24
- def self.support_autocorrect?(key)
25
- cop = Object.const_get "RuboCop::Cop::#{key.gsub(%r{/}, "::")}"
26
- cop.support_autocorrect? && cop.new(RuboCop::ConfigLoader.default_configuration).safe_autocorrect?
27
- rescue NameError
28
- false
48
+ def generate_header
49
+ [
50
+ horizontal_line,
51
+ header("Rubocop TODO searcher"),
52
+ title("Version", Rubocop::SafeTodoSearcher::VERSION),
53
+ title("Date", DateTime.now.strftime("%Y-%m-%d %H:%M:%S"))
54
+ ]
55
+ end
56
+
57
+ def header(text)
58
+ HighLine.new.color("++++++ #{text} ++++++", :bold)
59
+ end
60
+
61
+ def title(title, value, color = :green)
62
+ "#{HighLine.new.color(title, color)}: #{value}"
63
+ end
64
+
65
+ def horizontal_line(color = :none)
66
+ HighLine.new.color("--------------------------------------------------", :bold, color)
67
+ end
29
68
  end
30
69
  end
31
70
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-safe_todo_searcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - "ydah\n\n"
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-07 00:00:00.000000000 Z
11
+ date: 2022-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: highline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rubocop
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -179,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
193
  - !ruby/object:Gem::Version
180
194
  version: '0'
181
195
  requirements: []
182
- rubygems_version: 3.0.3
196
+ rubygems_version: 3.0.3.1
183
197
  signing_key:
184
198
  specification_version: 4
185
199
  summary: Check if Cop auto correct is available in .rubocop_todo.yml.