danger-regexp 1.0.1 → 1.1.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
  SHA256:
3
- metadata.gz: 212c7bce2b6f3ed6630e2ffa5e6f11ef22483ded3844bb8fba123a908b04123d
4
- data.tar.gz: 84c84c27b3000c23ae19dffca994c40d1970441cbdf6ea30c91d53620175bec2
3
+ metadata.gz: 28c69a790103ef6f30a1ca82b3a3f936cf5ac67a85aa46440ccbccf11e203eef
4
+ data.tar.gz: 8580783631028c35c43b30046e75524f5badf1e50302c8d480cd68b77a6c4287
5
5
  SHA512:
6
- metadata.gz: d212cee9266266aebbe765cee47d26d2797a7c474729216312f423b58dc68501f1d9cb9cca7add810007bebba04af53b3092238852dc89a3d631148f43f9119d
7
- data.tar.gz: e00ebb1859d89c41dbbf9e1b3e13cef934b31014cf0b88e199a3bfbe57eefb772fd9c7139afb1e8eab7d6f371bf6a5bfcebaafe4870d71dbbadf115f91665613
6
+ metadata.gz: b84e8f189db4bb9ada2a25a83db16d20326676762a6f5fd10681fab1bc9ee7c564c0bd428ad73a5a1c85ed91f63f678baa9705d196a6c8a97952dbf9f927833f
7
+ data.tar.gz: b0e7485459e079091c94ec3454dfbc654aa301cf5ddf651d2d79b2b6487dd812f8a77476021ad169a2239f8e0449e0665311292384a77f20980d7100839f8279
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change log
2
2
 
3
+ ## 1.1.0
4
+
5
+ - Post only first comment
6
+ - Add file option
7
+
3
8
  ## 1.0.1
4
9
 
5
10
  - Escape regexp
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-regexp (1.0.1)
4
+ danger-regexp (1.1.0)
5
5
  danger
6
6
  git_diff_parser (~> 3.1)
7
7
 
@@ -20,7 +20,7 @@ GEM
20
20
  colored2 (3.1.2)
21
21
  cork (0.3.0)
22
22
  colored2 (~> 3.1)
23
- danger (8.3.1)
23
+ danger (8.4.0)
24
24
  claide (~> 1.0)
25
25
  claide-plugins (>= 0.9.2)
26
26
  colored2 (~> 3.1)
@@ -34,7 +34,7 @@ GEM
34
34
  octokit (~> 4.7)
35
35
  terminal-table (>= 1, < 4)
36
36
  diff-lcs (1.4.4)
37
- faraday (1.5.1)
37
+ faraday (1.8.0)
38
38
  faraday-em_http (~> 1.0)
39
39
  faraday-em_synchrony (~> 1.0)
40
40
  faraday-excon (~> 1.1)
@@ -42,6 +42,7 @@ GEM
42
42
  faraday-net_http (~> 1.0)
43
43
  faraday-net_http_persistent (~> 1.1)
44
44
  faraday-patron (~> 1.0)
45
+ faraday-rack (~> 1.0)
45
46
  multipart-post (>= 1.2, < 3)
46
47
  ruby2_keywords (>= 0.0.4)
47
48
  faraday-em_http (1.0.0)
@@ -53,6 +54,7 @@ GEM
53
54
  faraday-net_http (1.0.1)
54
55
  faraday-net_http_persistent (1.2.0)
55
56
  faraday-patron (1.0.0)
57
+ faraday-rack (1.0.0)
56
58
  git (1.9.1)
57
59
  rchardet (~> 1.8)
58
60
  git_diff_parser (3.2.0)
@@ -95,9 +97,9 @@ GEM
95
97
  sawyer (0.8.2)
96
98
  addressable (>= 2.3.5)
97
99
  faraday (> 0.8, < 2.0)
98
- terminal-table (3.0.1)
100
+ terminal-table (3.0.2)
99
101
  unicode-display_width (>= 1.1.1, < 3)
100
- unicode-display_width (2.0.0)
102
+ unicode-display_width (2.1.0)
101
103
 
102
104
  PLATFORMS
103
105
  x86_64-linux
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  ```ruby
24
24
  regexp.lint to
25
- match(/hello world/, <<~MESSAGE)
25
+ match(/hello world/, <<~MESSAGE, file: /README\.md/)
26
26
  Don't use hello world, just use hello instead.
27
27
  MESSAGE
28
28
  end
data/devfile.yaml ADDED
@@ -0,0 +1,18 @@
1
+ apiVersion: 1.0.0
2
+ metadata:
3
+ generateName: danger-
4
+ projects:
5
+ - name: danger-regexp
6
+ source:
7
+ location: "https://github.com/mtsmfm/danger-regexp.git"
8
+ type: github
9
+ components:
10
+ - id: esbenp/prettier-vscode/latest
11
+ type: chePlugin
12
+ - mountSources: true
13
+ memoryLimit: 4Gi
14
+ type: dockerimage
15
+ alias: ruby
16
+ image: "ghcr.io/mtsmfm/devfiles/ruby:3.0"
17
+ - id: redhat/vscode-yaml/latest
18
+ type: chePlugin
@@ -1,5 +1,5 @@
1
1
  module Danger
2
2
  module Regexp
3
- VERSION = "1.0.1"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
data/lib/danger_plugin.rb CHANGED
@@ -2,40 +2,41 @@ require 'git_diff_parser'
2
2
 
3
3
  module Danger
4
4
  class DangerRegexp < Plugin
5
- MAX_COMMENT_COUNT = 5
5
+ MAX_COMMENT_COUNT = 1
6
6
 
7
7
  ChangedLine = Struct.new(:file, :number, :content, keyword_init: true)
8
+ MatchArgs = Struct.new(:regexps, :message, :file, keyword_init: true)
8
9
 
9
10
  def lint(&block)
10
- @map = {}
11
+ @data = []
11
12
 
12
13
  instance_eval(&block)
13
14
 
14
- @map.each do |regexp, message|
15
+ @data.each do |match_args|
15
16
  count = 0
16
17
 
17
- target_lines = changed_lines.select do |line|
18
- line.content.match?(regexp)
19
- end
18
+ match_args.regexps.each do |regexp|
19
+ target_lines = changed_lines.select do |line|
20
+ (match_args.file ? line.file.match?(match_args.file) : true) && line.content.match?(regexp)
21
+ end
20
22
 
21
- target_lines.first(MAX_COMMENT_COUNT).each do |line|
22
- markdown(message, file: line.file, line: line.number)
23
- end
23
+ target_lines.first(MAX_COMMENT_COUNT).each do |line|
24
+ markdown(match_args.message, file: line.file, line: line.number)
25
+ end
24
26
 
25
- if target_lines.size > MAX_COMMENT_COUNT
26
- warn <<~MSG
27
- Regexp `#{regexp.inspect}` matched too many lines (#{target_lines.size} lines). Only first #{MAX_COMMENT_COUNT} comments are posted.
28
- MSG
27
+ if target_lines.size > MAX_COMMENT_COUNT
28
+ warn <<~MSG
29
+ Regexp `#{regexp.inspect}` matched too many lines (#{target_lines.size} lines). Only first comment is posted.
30
+ MSG
31
+ end
29
32
  end
30
33
  end
31
34
  end
32
35
 
33
36
  private
34
37
 
35
- def match(*regexps, message)
36
- regexps.each do |regexp|
37
- @map[regexp] = message
38
- end
38
+ def match(*regexps, message, file: nil)
39
+ @data << MatchArgs.new(regexps: regexps, message: message, file: file)
39
40
  end
40
41
 
41
42
  def changed_lines
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-regexp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fumiaki MATSUSHIMA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-31 00:00:00.000000000 Z
11
+ date: 2021-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git_diff_parser
@@ -82,7 +82,6 @@ files:
82
82
  - ".github/workflows/test.yml"
83
83
  - ".gitignore"
84
84
  - ".rspec"
85
- - ".travis.yml"
86
85
  - CHANGELOG.md
87
86
  - CODE_OF_CONDUCT.md
88
87
  - Gemfile
@@ -93,6 +92,7 @@ files:
93
92
  - bin/console
94
93
  - bin/setup
95
94
  - danger-regexp.gemspec
95
+ - devfile.yaml
96
96
  - lib/danger/regexp.rb
97
97
  - lib/danger/regexp/version.rb
98
98
  - lib/danger_plugin.rb
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.5.1
7
- before_install: gem install bundler -v 1.16.3