danger-periphery 0.2.2 → 0.2.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/lib/danger_plugin.rb +31 -0
- data/lib/periphery/installer.rb +46 -0
- data/lib/periphery/json_parser.rb +5 -9
- data/lib/periphery.rb +1 -0
- data/lib/version.rb +1 -1
- metadata +22 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9c9c3f228ac9ddf39d67684faca46dfaf969f9576a566a045b2ef0d50a714473
|
|
4
|
+
data.tar.gz: 7c60528ef9459c67a57c74566f6c76beb8871e04557afde65c8d8a05ffc81db1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f51ab7485b787644820d4df9a87a4b9f2d52be587792c03271a9f2defe8710697f1bc10578fa6ecf49bd2bc596807e79606c6ec888851bf6a8833c9a18a24a5
|
|
7
|
+
data.tar.gz: 92db186ee32f74f37d38b99787338bfae9101b5b4971f41a051a3bf0e19f2b888db542a735ecb6c9fefe87d7bd88f40d33df1703b9b8782b08c8460bda9f103a
|
data/lib/danger_plugin.rb
CHANGED
|
@@ -102,11 +102,42 @@ module Danger
|
|
|
102
102
|
@postprocessor = block
|
|
103
103
|
end
|
|
104
104
|
|
|
105
|
+
# @deprecated Use {#scan} with block instead.
|
|
106
|
+
#
|
|
107
|
+
# A block to manipulate each warning before it is displayed.
|
|
108
|
+
#
|
|
109
|
+
# @param [Proc] postprocessor Block to process each warning just before showing it.
|
|
110
|
+
# The Proc is called like `postprocessor(path, line, column, message)`
|
|
111
|
+
# where `path` is a String that indicates the file path the warning points out,
|
|
112
|
+
# `line` and `column` are Integers that indicates the location in the file,
|
|
113
|
+
# `message` is a String message body of the warning.
|
|
114
|
+
# The Proc returns either of the following:
|
|
115
|
+
# 1. an Array contains `path`, `line`, `column`, `message` in this order.
|
|
116
|
+
# 2. true
|
|
117
|
+
# 3. false or nil
|
|
118
|
+
# If it returns falsy value, the warning will be suppressed.
|
|
119
|
+
# If it returns `true`, the warning will be displayed as-is.
|
|
120
|
+
# Otherwise it returns an Array, the warning is newly created by the returned array
|
|
121
|
+
# and displayed.
|
|
122
|
+
# @return [void]
|
|
105
123
|
def postprocessor=(postprocessor)
|
|
106
124
|
deprecate_in_favor_of_scan
|
|
107
125
|
@postprocessor = postprocessor
|
|
108
126
|
end
|
|
109
127
|
|
|
128
|
+
# Download and install Periphery executable binary.
|
|
129
|
+
#
|
|
130
|
+
# @param [String, Symbol] version The version of Periphery you want to install.
|
|
131
|
+
# `:latest` is treated as special keyword that specifies the latest version.
|
|
132
|
+
# @param [String] path The path to install Periphery including the filename itself.
|
|
133
|
+
# @param [Boolean] force If `true`, an existing file will be overwritten. Otherwise an error occurs.
|
|
134
|
+
# @return [void]
|
|
135
|
+
def install(version: :latest, path: 'periphery', force: false)
|
|
136
|
+
installer = Periphery::Installer.new(version)
|
|
137
|
+
installer.install(path, force: force)
|
|
138
|
+
self.binary_path = File.absolute_path(path)
|
|
139
|
+
end
|
|
140
|
+
|
|
110
141
|
private
|
|
111
142
|
|
|
112
143
|
def files_in_diff
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'net/http'
|
|
5
|
+
require 'open-uri'
|
|
6
|
+
require 'rubygems/version'
|
|
7
|
+
require 'zip'
|
|
8
|
+
|
|
9
|
+
module Periphery
|
|
10
|
+
# Downloads Periphery binary executable and install it to the specified path.
|
|
11
|
+
class Installer
|
|
12
|
+
def initialize(version_spec)
|
|
13
|
+
@version_spec = version_spec
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def install(dest_path, force: false)
|
|
17
|
+
URI.parse(download_url).open do |src|
|
|
18
|
+
entry = Zip::File.open_buffer(src).get_entry('periphery')
|
|
19
|
+
entry.restore_permissions = true
|
|
20
|
+
FileUtils.rm_f(dest_path) if force
|
|
21
|
+
entry.extract(dest_path)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def version
|
|
26
|
+
@version ||= @version_spec == :latest ? fetch_latest_version : @version_spec
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def download_url
|
|
32
|
+
if Gem::Version.new(version) >= Gem::Version.new('2.14.0')
|
|
33
|
+
"https://github.com/peripheryapp/periphery/releases/download/#{version}/periphery-#{version}.zip"
|
|
34
|
+
else
|
|
35
|
+
"https://github.com/peripheryapp/periphery/releases/download/#{version}/periphery-v#{version}.zip"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def fetch_latest_version
|
|
40
|
+
Net::HTTP.start('github.com', port: 443, use_ssl: true) do |http|
|
|
41
|
+
response = http.head('/peripheryapp/periphery/releases/latest')
|
|
42
|
+
URI.parse(response['location']).path.split('/').last
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -9,7 +9,7 @@ module Periphery
|
|
|
9
9
|
def parse(string)
|
|
10
10
|
JSON.parse(string).map do |entry|
|
|
11
11
|
path, line, column = parse_location(entry['location'])
|
|
12
|
-
message = compose_message(*entry.slice('name', 'kind', 'hints').values)
|
|
12
|
+
message = compose_message(*entry.slice('name', 'kind', 'hints', 'modules').values)
|
|
13
13
|
ScanResult.new(path, line, column, message)
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -28,14 +28,14 @@ module Periphery
|
|
|
28
28
|
raise ArgumentError, "#{location} is not in a valid format"
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
def compose_message(name, kind, hints)
|
|
31
|
+
def compose_message(name, kind, hints, modules = [])
|
|
32
32
|
return 'unused' unless name
|
|
33
33
|
|
|
34
34
|
# Assumes hints contains only one item.
|
|
35
35
|
# https://github.com/peripheryapp/periphery/blob/2.9.0/Sources/Frontend/Formatters/JsonFormatter.swift#L27
|
|
36
36
|
# https://github.com/peripheryapp/periphery/blob/2.9.0/Sources/Frontend/Formatters/JsonFormatter.swift#L42
|
|
37
37
|
hint = hints[0]
|
|
38
|
-
+"#{display_name(kind).capitalize} '#{name}' #{describe_hint(hint)}"
|
|
38
|
+
+"#{display_name(kind).capitalize} '#{name}' #{describe_hint(hint, modules)}"
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def display_name(kind)
|
|
@@ -49,17 +49,13 @@ module Periphery
|
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
def describe_hint(hint)
|
|
52
|
+
def describe_hint(hint, modules)
|
|
53
53
|
case hint
|
|
54
54
|
when 'unused' then 'is unused'
|
|
55
55
|
when 'assignOnlyProperty' then 'is assigned, but never used'
|
|
56
56
|
when 'redundantProtocol' then "is redundant as it's never used as an existential type"
|
|
57
57
|
when 'redundantConformance' then 'conformance is redundant'
|
|
58
|
-
|
|
59
|
-
# unlike other formatters can output `outside of FooModule`.
|
|
60
|
-
# This is known problem and may be fixed in future Periphery's release.
|
|
61
|
-
# See the status of https://github.com/peripheryapp/periphery/pull/519
|
|
62
|
-
when 'redundantPublicAccessibility' then 'is declared public, but not used outside of the module'
|
|
58
|
+
when 'redundantPublicAccessibility' then "is declared public, but not used outside of #{modules.join(', ')}"
|
|
63
59
|
else ''
|
|
64
60
|
end
|
|
65
61
|
end
|
data/lib/periphery.rb
CHANGED
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: danger-periphery
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryosuke Ito
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-07-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: danger-plugin-api
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rubyzip
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.0'
|
|
27
41
|
description: A Danger plugin to detect unused codes.
|
|
28
42
|
email:
|
|
29
43
|
- rito.0305@gmail.com
|
|
@@ -34,6 +48,7 @@ files:
|
|
|
34
48
|
- lib/danger_plugin.rb
|
|
35
49
|
- lib/periphery.rb
|
|
36
50
|
- lib/periphery/checkstyle_parser.rb
|
|
51
|
+
- lib/periphery/installer.rb
|
|
37
52
|
- lib/periphery/json_parser.rb
|
|
38
53
|
- lib/periphery/runner.rb
|
|
39
54
|
- lib/periphery/scan_result.rb
|
|
@@ -43,7 +58,7 @@ licenses:
|
|
|
43
58
|
- MIT
|
|
44
59
|
metadata:
|
|
45
60
|
rubygems_mfa_required: 'true'
|
|
46
|
-
post_install_message:
|
|
61
|
+
post_install_message:
|
|
47
62
|
rdoc_options: []
|
|
48
63
|
require_paths:
|
|
49
64
|
- lib
|
|
@@ -51,15 +66,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
51
66
|
requirements:
|
|
52
67
|
- - ">="
|
|
53
68
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 2.
|
|
69
|
+
version: 2.7.0
|
|
55
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
71
|
requirements:
|
|
57
72
|
- - ">="
|
|
58
73
|
- !ruby/object:Gem::Version
|
|
59
74
|
version: '0'
|
|
60
75
|
requirements: []
|
|
61
|
-
rubygems_version: 3.
|
|
62
|
-
signing_key:
|
|
76
|
+
rubygems_version: 3.4.6
|
|
77
|
+
signing_key:
|
|
63
78
|
specification_version: 4
|
|
64
79
|
summary: A Danger plugin to detect unused codes.
|
|
65
80
|
test_files: []
|