netsoft-danger 0.3.3 → 0.3.8

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.
metadata CHANGED
@@ -1,23 +1,37 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsoft-danger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - urkle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-13 00:00:00.000000000 Z
11
+ date: 2020-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: danger
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
18
32
  - !ruby/object:Gem::Version
19
33
  version: '0'
20
- type: :development
34
+ type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
@@ -25,89 +39,103 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
- name: danger
42
+ name: thor
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '5.0'
47
+ version: '0'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: '5.0'
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rubocop
56
+ name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: 0.74.0
48
- type: :runtime
61
+ version: '0'
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
- version: 0.74.0
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rubocop-rails
70
+ name: netsoft-rubocop
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - '='
60
74
  - !ruby/object:Gem::Version
61
- version: 2.2.1
62
- type: :runtime
75
+ version: 1.0.1
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: 2.2.1
82
+ version: 1.0.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.74.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.74.0
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rubocop-performance
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
- - - "~>"
101
+ - - '='
74
102
  - !ruby/object:Gem::Version
75
- version: 1.4.1
76
- type: :runtime
103
+ version: 1.5.2
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
- version: 1.4.1
110
+ version: 1.5.2
83
111
  - !ruby/object:Gem::Dependency
84
- name: rubocop-rspec
112
+ name: rubocop-rails
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
- - - "~>"
115
+ - - '='
88
116
  - !ruby/object:Gem::Version
89
- version: 1.35.0
90
- type: :runtime
117
+ version: 2.4.2
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
- version: 1.35.0
124
+ version: 2.4.2
97
125
  - !ruby/object:Gem::Dependency
98
- name: thor
126
+ name: rubocop-rspec
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
- - - ">="
129
+ - - '='
102
130
  - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
131
+ version: 1.38.1
132
+ type: :development
105
133
  prerelease: false
106
134
  version_requirements: !ruby/object:Gem::Requirement
107
135
  requirements:
108
- - - ">="
136
+ - - '='
109
137
  - !ruby/object:Gem::Version
110
- version: '0'
138
+ version: 1.38.1
111
139
  description: Packages a Dangerfile to be used with Danger.
112
140
  email: []
113
141
  executables:
@@ -117,21 +145,20 @@ extra_rdoc_files: []
117
145
  files:
118
146
  - ".circleci/config.yml"
119
147
  - ".gitignore"
148
+ - ".rubocop.yml"
149
+ - CHANGELOG.md
120
150
  - Dangerfile
121
151
  - Gemfile
122
152
  - README.md
123
153
  - Rakefile
124
154
  - bin/netsoft-circle
155
+ - bin/setup-rubygems.sh
125
156
  - bin/tag_check.sh
126
157
  - dangerfiles/issue.js
127
158
  - dangerfiles/pr.js
128
- - lib/netsoft-danger.rb
129
- - lib/netsoft-danger/cops.rb
130
- - lib/netsoft-danger/cops/netsoft/auth_http_positional_arguments.rb
131
159
  - lib/netsoft-danger/version.rb
132
160
  - netsoft-danger.gemspec
133
161
  - package.json
134
- - rubocop/config-2019-08-12.yml
135
162
  - settings-peril.json
136
163
  - yarn.lock
137
164
  homepage: https://github.com/NetsoftHoldings/danger
@@ -1,3 +0,0 @@
1
- require 'rubocop'
2
-
3
- require_relative 'netsoft-danger/cops'
@@ -1 +0,0 @@
1
- require_relative 'cops/netsoft/auth_http_positional_arguments'
@@ -1,142 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rubocop/cop/mixin/target_rails_version'
4
-
5
- module RuboCop
6
- module Cop
7
- module Netsoft
8
- # This cop is used to identify usages of http methods like `get`, `post`,
9
- # `put`, `patch` without the usage of keyword arguments in your tests and
10
- # change them to use keyword args. This cop only applies to Rails >= 5.
11
- # If you are running Rails < 5 you should disable the
12
- # Netsoft/HttpPositionalArguments cop or set your TargetRailsVersion in your
13
- # .rubocop.yml file to 4.0, etc.
14
- #
15
- # @example
16
- # # bad
17
- # get :new, { user_id: 1}
18
- #
19
- # # good
20
- # get :new, params: { user_id: 1 }
21
- class AuthHttpPositionalArguments < Cop
22
- extend RuboCop::Cop::TargetRailsVersion
23
-
24
- MSG = 'Use keyword arguments instead of ' \
25
- 'positional arguments for http call: `%<verb>s`.'.freeze
26
- KEYWORD_ARGS = %i[
27
- method params session body flash xhr as headers env
28
- ].freeze
29
- HTTP_METHODS = %i[get post put patch delete head].freeze
30
- HTTP_AUTH_METHODS = %i[get_with post_with put_with patch_with delete_with].freeze
31
-
32
- minimum_target_rails_version 5.0
33
-
34
- def_node_matcher :http_request?, <<-PATTERN
35
- (send nil? {#{HTTP_METHODS.map(&:inspect).join(' ')}} !nil? $_ ...)
36
- PATTERN
37
-
38
- def_node_matcher :http_auth_request?, <<-PATTERN
39
- (send nil? {#{HTTP_AUTH_METHODS.map(&:inspect).join(' ')}} !nil? !nil? $_ ...)
40
- PATTERN
41
-
42
- def on_send(node)
43
- http_request?(node) do |data|
44
- return unless needs_conversion?(data)
45
-
46
- add_offense(node, location: :selector,
47
- message: format(MSG, verb: node.method_name))
48
- end
49
-
50
- http_auth_request?(node) do |data|
51
- return unless auth_needs_conversion?(data)
52
-
53
- add_offense(node, location: :selector,
54
- message: format(MSG, verb: node.method_name))
55
- end
56
- end
57
-
58
- # given a pre Rails 5 method: get :new, {user_id: @user.id}, {}
59
- #
60
- # @return lambda of auto correct procedure
61
- # the result should look like:
62
- # get :new, params: { user_id: @user.id }, session: {}
63
- # the http_method is the method used to call the controller
64
- # the controller node can be a symbol, method, object or string
65
- # that represents the path/action on the Rails controller
66
- # the data is the http parameters and environment sent in
67
- # the Rails 5 http call
68
- def autocorrect(node)
69
- has_auth = HTTP_AUTH_METHODS.include?(node.method_name.to_sym)
70
- if has_auth
71
- user, http_path, *data = *node.arguments
72
- else
73
- http_path, *data = *node.arguments
74
- end
75
-
76
- controller_action = http_path.source
77
- params = convert_hash_data(data.first, 'params')
78
- session = convert_hash_data(data.last, 'session') if data.size > 1
79
- # the range of the text to replace, which is the whole line
80
- code_to_replace = node.loc.expression
81
- # what to replace with
82
- format = parentheses_format(node)
83
- new_code = format(format, name: node.method_name,
84
- action: has_auth ? [user.source, controller_action].join(',') : controller_action,
85
- params: params, session: session)
86
- ->(corrector) { corrector.replace(code_to_replace, new_code) }
87
- end
88
-
89
- private
90
-
91
- def needs_conversion?(data)
92
- return true unless data.hash_type?
93
-
94
- data.each_pair.none? do |pair|
95
- special_keyword_arg?(pair.key) ||
96
- format_arg?(pair.key) && data.pairs.one?
97
- end
98
- end
99
-
100
- def auth_needs_conversion?(data)
101
- return true unless data.hash_type?
102
-
103
- data.each_pair.none? do |pair|
104
- special_keyword_arg?(pair.key) ||
105
- format_arg?(pair.key) && data.pairs.one?
106
- end
107
- end
108
-
109
- def special_keyword_arg?(node)
110
- node.sym_type? && KEYWORD_ARGS.include?(node.value)
111
- end
112
-
113
- def format_arg?(node)
114
- node.sym_type? && node.value == :format
115
- end
116
-
117
- def convert_hash_data(data, type)
118
- return '' if data.hash_type? && data.empty?
119
-
120
- hash_data = if data.hash_type?
121
- format('{ %<data>s }',
122
- data: data.pairs.map(&:source).join(', '))
123
- else
124
- # user supplies an object,
125
- # no need to surround with braces
126
- data.source
127
- end
128
-
129
- format(', %<type>s: %<hash_data>s', type: type, hash_data: hash_data)
130
- end
131
-
132
- def parentheses_format(node)
133
- if parentheses?(node)
134
- '%<name>s(%<action>s%<params>s%<session>s)'
135
- else
136
- '%<name>s %<action>s%<params>s%<session>s'
137
- end
138
- end
139
- end
140
- end
141
- end
142
- end
@@ -1,95 +0,0 @@
1
- require:
2
- - netsoft-danger
3
- - rubocop-rails
4
- - rubocop-performance
5
- - rubocop-rspec
6
-
7
- AllCops:
8
- TargetRubyVersion: 2.4
9
- TargetRailsVersion: 5.2
10
- DisplayStyleGuide: true
11
- StyleGuideBaseURL: https://rubystyle.guide
12
- Exclude:
13
- - 'db/**/*'
14
- - 'coverage/**/*'
15
- - 'log/**/*'
16
- - 'public/**/*'
17
- - 'tmp/**/*'
18
- - 'spec/dummy/**/*'
19
- - 'vendor/**/*'
20
-
21
- Naming/RescuedExceptionsVariableName:
22
- PreferredName: ex
23
- Naming/UncommunicativeMethodParamName:
24
- AllowedNames:
25
- - me
26
- - ex
27
-
28
- Layout/AlignHash:
29
- EnforcedHashRocketStyle: table
30
- EnforcedColonStyle: table
31
- Layout/ExtraSpacing:
32
- AllowForAlignment: true
33
- Layout/IndentAssignment:
34
- IndentationWidth: 4
35
- Layout/IndentFirstArrayElement:
36
- EnforcedStyle: consistent
37
- IndentationWidth: 4
38
- Layout/IndentFirstHashElement:
39
- EnforcedStyle: consistent
40
- IndentationWidth: 4
41
- Layout/SpaceInsideBlockBraces:
42
- EnforcedStyle: no_space
43
- SpaceBeforeBlockParameters: false
44
- Layout/SpaceInsideHashLiteralBraces:
45
- EnforcedStyle: no_space
46
-
47
- Lint/AmbiguousBlockAssociation:
48
- Exclude:
49
- - spec/**/*
50
-
51
- Rails:
52
- Enabled: true
53
- Rails/HttpPositionalArguments:
54
- Enabled: false
55
- Rails/SkipsModelValidations:
56
- Whitelist:
57
- - touch
58
- - update_attribute
59
- - update_counters
60
- - increment_counter
61
- - decrement_counter
62
- Netsoft/AuthHttpPositionalArguments:
63
- Enabled: true
64
- Include:
65
- - 'spec/controllers/**/*'
66
-
67
- RSpec/ExpectChange:
68
- EnforcedStyle: block
69
- RSpec/ImplicitSubject:
70
- Enabled: false
71
- RSpec/MessageSpies:
72
- Enabled: false
73
- RSpec/NamedSubject:
74
- Enabled: false
75
- RSpec/NestedGroups:
76
- Enabled: false
77
- RSpec/NotToNot:
78
- EnforcedStyle: to_not
79
-
80
- Style/AndOr:
81
- EnforcedStyle: conditionals
82
- Style/BlockDelimiters:
83
- EnforcedStyle: semantic
84
- AllowBracesOnProceduralOneLiners: true
85
- Style/MultilineBlockChain:
86
- Enabled: false
87
- Style/RescueModifier:
88
- Enabled: false
89
- Style/TrailingCommaInArrayLiteral:
90
- EnforcedStyleForMultiline: comma
91
- Style/TrailingCommaInHashLiteral:
92
- EnforcedStyleForMultiline: comma
93
-
94
- Metrics:
95
- Enabled: false