smart_todo 1.3.0 → 1.4.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 +4 -4
- data/.github/workflows/build.yml +2 -2
- data/.github/workflows/cla.yml +22 -0
- data/Gemfile.lock +1 -1
- data/LICENSE.txt +1 -1
- data/dev.yml +5 -1
- data/lib/smart_todo/dispatchers/output.rb +1 -1
- data/lib/smart_todo/slack_client.rb +10 -9
- data/lib/smart_todo/version.rb +1 -1
- data/lib/smart_todo_cop.rb +24 -9
- data/service.yml +0 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b21d53a3957ea19430b3726fd82fefeceef262330ead8eb9ef1ef087acd29bb4
|
4
|
+
data.tar.gz: 3927e36c7c059e90613ceec82e8d00efc8c7e6ceceb6183d05a5cd59c466086c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f92dd70f82426b84d8a651a9963dffbf6b66017c484b25371b68c16495bf2cdb28faba9fdb31a0ab56ffbb5f848f1a877375379c4c94ca946bb16d9630d7d075
|
7
|
+
data.tar.gz: 69aa57c5583a6adba8320783171eeaef3814e9e758c81b3c81bbd455c3d238d72d145be44c5fa6732764d7561beac2c19181f8344462f209346572bb23f6bf3d
|
data/.github/workflows/build.yml
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Contributor License Agreement (CLA)
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request_target:
|
5
|
+
types: [opened, synchronize]
|
6
|
+
issue_comment:
|
7
|
+
types: [created]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
cla:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
if: |
|
13
|
+
(github.event.issue.pull_request
|
14
|
+
&& !github.event.issue.pull_request.merged_at
|
15
|
+
&& contains(github.event.comment.body, 'signed')
|
16
|
+
)
|
17
|
+
|| (github.event.pull_request && !github.event.pull_request.merged)
|
18
|
+
steps:
|
19
|
+
- uses: Shopify/shopify-cla-action@v1
|
20
|
+
with:
|
21
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
22
|
+
cla-token: ${{ secrets.CLA_TOKEN }}
|
data/Gemfile.lock
CHANGED
data/LICENSE.txt
CHANGED
data/dev.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "cgi"
|
3
4
|
require "net/http"
|
4
5
|
require "json"
|
5
6
|
|
@@ -37,14 +38,14 @@ module SmartTodo
|
|
37
38
|
# @param email [String]
|
38
39
|
# @return [Hash]
|
39
40
|
#
|
40
|
-
# @raise [Net::HTTPError] in case the
|
41
|
-
# @raise [SlackClient::Error] in case Slack
|
41
|
+
# @raise [Net::HTTPError] in case the request to Slack failed
|
42
|
+
# @raise [SlackClient::Error] in case Slack returns a { ok: false } in the body
|
42
43
|
#
|
43
44
|
# @see https://api.slack.com/methods/users.lookupByEmail
|
44
45
|
def lookup_user_by_email(email)
|
45
46
|
headers = { "Content-Type" => "application/x-www-form-urlencoded" }
|
46
47
|
|
47
|
-
request(:get, "/api/users.lookupByEmail?email=#{email}", nil, headers)
|
48
|
+
request(:get, "/api/users.lookupByEmail?email=#{CGI.escape(email)}", nil, headers)
|
48
49
|
end
|
49
50
|
|
50
51
|
# Send a message to a Slack channel or to a user
|
@@ -53,8 +54,8 @@ module SmartTodo
|
|
53
54
|
# @param text [String] The message to send
|
54
55
|
# @return [Hash]
|
55
56
|
#
|
56
|
-
# @raise [Net::HTTPError] in case the
|
57
|
-
# @raise [SlackClient::Error] in case Slack
|
57
|
+
# @raise [Net::HTTPError] in case the request to Slack failed
|
58
|
+
# @raise [SlackClient::Error] in case Slack returns a { ok: false } in the body
|
58
59
|
#
|
59
60
|
# @see https://api.slack.com/methods/chat.postMessage
|
60
61
|
def post_message(channel, text)
|
@@ -68,8 +69,8 @@ module SmartTodo
|
|
68
69
|
# @param data [String] JSON encoded data when making a POST request
|
69
70
|
# @param headers [Hash]
|
70
71
|
#
|
71
|
-
# @raise [Net::HTTPError] in case the
|
72
|
-
# @raise [SlackClient::Error] in case Slack
|
72
|
+
# @raise [Net::HTTPError] in case the request to Slack failed
|
73
|
+
# @raise [SlackClient::Error] in case Slack returns a { ok: false } in the body
|
73
74
|
def request(method, endpoint, data = nil, headers = {})
|
74
75
|
response = case method
|
75
76
|
when :post, :patch
|
@@ -87,8 +88,8 @@ module SmartTodo
|
|
87
88
|
# (Net::HTTPOK, Net::HTTPNotFound ...)
|
88
89
|
# @return [Hash]
|
89
90
|
#
|
90
|
-
# @raise [Net::HTTPError] in case the
|
91
|
-
# @raise [SlackClient::Error] in case Slack
|
91
|
+
# @raise [Net::HTTPError] in case the request to Slack failed
|
92
|
+
# @raise [SlackClient::Error] in case Slack returns a { ok: false } in the body
|
92
93
|
def slack_response!(response)
|
93
94
|
raise(Net::HTTPError.new("Request to slack failed", response)) unless response.code_type < Net::HTTPSuccess
|
94
95
|
body = JSON.parse(response.body)
|
data/lib/smart_todo/version.rb
CHANGED
data/lib/smart_todo_cop.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "smart_todo
|
3
|
+
require "smart_todo"
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
@@ -10,29 +10,44 @@ module RuboCop
|
|
10
10
|
#
|
11
11
|
# @see https://rubocop.readthedocs.io/en/latest/extensions/#loading-extensions
|
12
12
|
class SmartTodoCop < Cop
|
13
|
-
|
14
|
-
|
13
|
+
HELP = "For more info please look at https://github.com/Shopify/smart_todo/wiki/Syntax"
|
14
|
+
MSG = "Don't write regular TODO comments. Write SmartTodo compatible syntax comments. #{HELP}"
|
15
15
|
|
16
16
|
# @param processed_source [RuboCop::ProcessedSource]
|
17
17
|
# @return [void]
|
18
18
|
def investigate(processed_source)
|
19
19
|
processed_source.comments.each do |comment|
|
20
20
|
next unless /^#\sTODO/ =~ comment.text
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
metadata = metadata(comment.text)
|
22
|
+
if !smart_todo?(metadata)
|
23
|
+
add_offense(comment)
|
24
|
+
elsif (methods = invalid_event_methods(metadata.events)).any?
|
25
|
+
add_offense(comment, message: "Invalid event method(s): #{methods.join(", ")}. #{HELP}")
|
26
|
+
end
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
30
|
+
private
|
31
|
+
|
27
32
|
# @param comment [String]
|
28
|
-
# @return [
|
29
|
-
def
|
30
|
-
|
33
|
+
# @return [SmartTodo::Parser::Visitor]
|
34
|
+
def metadata(comment)
|
35
|
+
::SmartTodo::Parser::MetadataParser.parse(comment.gsub(/^#/, ""))
|
36
|
+
end
|
31
37
|
|
38
|
+
# @param metadata [SmartTodo::Parser::Visitor]
|
39
|
+
# @return [true, false]
|
40
|
+
def smart_todo?(metadata)
|
32
41
|
metadata.events.any? &&
|
33
42
|
metadata.events.all? { |event| event.is_a?(::SmartTodo::Parser::MethodNode) } &&
|
34
43
|
metadata.assignees.any?
|
35
44
|
end
|
45
|
+
|
46
|
+
# @param metadata [Array<SmartTodo::Parser::MethodNode>]
|
47
|
+
# @return [Array<String>]
|
48
|
+
def invalid_event_methods(events)
|
49
|
+
events.map(&:method_name).reject { |method| ::SmartTodo::Events.respond_to?(method) }
|
50
|
+
end
|
36
51
|
end
|
37
52
|
end
|
38
53
|
end
|
data/service.yml
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
classification: library
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_todo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rexml
|
@@ -92,6 +92,7 @@ extensions: []
|
|
92
92
|
extra_rdoc_files: []
|
93
93
|
files:
|
94
94
|
- ".github/workflows/build.yml"
|
95
|
+
- ".github/workflows/cla.yml"
|
95
96
|
- ".github/workflows/rubocop.yml"
|
96
97
|
- ".gitignore"
|
97
98
|
- ".rubocop.yml"
|
@@ -148,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
149
|
- !ruby/object:Gem::Version
|
149
150
|
version: '0'
|
150
151
|
requirements: []
|
151
|
-
rubygems_version: 3.
|
152
|
+
rubygems_version: 3.3.3
|
152
153
|
signing_key:
|
153
154
|
specification_version: 4
|
154
155
|
summary: Enhance todo's comments in your codebase.
|