smart_todo 1.3.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc3a4665a0110180692321fbdd788be8df4155de16bf75b2967f4c330a759e72
4
- data.tar.gz: 414a198aa06035126890b002f6552779c73d9f6f84eeeaa904ba2132daa7d4d9
3
+ metadata.gz: b21d53a3957ea19430b3726fd82fefeceef262330ead8eb9ef1ef087acd29bb4
4
+ data.tar.gz: 3927e36c7c059e90613ceec82e8d00efc8c7e6ceceb6183d05a5cd59c466086c
5
5
  SHA512:
6
- metadata.gz: 8e0c57b0849a90cd1be9699d264167e7286d622eb42e02cc7dd13231ab41d76d815a455a65571f3890dda7c79dc0228692b0c72c37c50337826df137d0c0f0df
7
- data.tar.gz: a62b94332abe655cb418d0238eaa24e86db0e48b109877b8192265a244795624a2188cffeb0be429f0204683394b992ce73a0932efc322b4c3ba589cadcd0af4
6
+ metadata.gz: f92dd70f82426b84d8a651a9963dffbf6b66017c484b25371b68c16495bf2cdb28faba9fdb31a0ab56ffbb5f848f1a877375379c4c94ca946bb16d9630d7d075
7
+ data.tar.gz: 69aa57c5583a6adba8320783171eeaef3814e9e758c81b3c81bbd455c3d238d72d145be44c5fa6732764d7561beac2c19181f8344462f209346572bb23f6bf3d
@@ -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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_todo (1.3.1)
4
+ smart_todo (1.4.3)
5
5
  rexml
6
6
 
7
7
  GEM
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Shopify
3
+ Copyright (c) 2019-present Shopify
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmartTodo
4
- VERSION = "1.3.1"
4
+ VERSION = "1.4.3"
5
5
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "smart_todo/parser/metadata_parser"
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
- MSG = "Don't write regular TODO comments. Write SmartTodo compatible syntax comments." \
14
- "For more info please look at https://github.com/shopify/smart_todo"
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
- next if smart_todo?(comment.text)
22
-
23
- add_offense(comment)
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 [true, false]
29
- def smart_todo?(comment)
30
- metadata = ::SmartTodo::Parser::MetadataParser.parse(comment.gsub(/^#/, ""))
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.1
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: 2021-11-23 00:00:00.000000000 Z
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.2.20
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.