pronto-flay 0.11.0 → 0.11.1
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/README.md +10 -0
- data/lib/pronto/flay/version.rb +1 -1
- data/lib/pronto/flay.rb +26 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef63495669d107a5ba8a6960b2cdd9bde37714149b41000cc60dd016c0855d52
|
4
|
+
data.tar.gz: ee6fa73a905431c80d8b44dc7d55c3c83d24c648372aaf32af2c474dc866bc6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2930f2d17f894ac20873911cbc6c23797f118b15d1be1feef39c4b06663afde3076085135554480159146d9b9f571ac0a8c59b4ee72d7d5a31541c0fcf8d0ce3
|
7
|
+
data.tar.gz: a6301dd3d443bf1237797821e0550f84d922166b93b9a703294aff761c851cb740c8b5cd58b14862ed5eac99843b19d2990e6df964c81b7ce24150e2d92a4960
|
data/README.md
CHANGED
@@ -10,3 +10,13 @@ Pronto runner for [Flay](https://github.com/seattlerb/flay), structural similari
|
|
10
10
|
# Configuration
|
11
11
|
|
12
12
|
Configuring excludes Using [.flayignore](https://github.com/seattlerb/flay/blob/92039b66a479f3b8a8a1204c5733e35463e66995/README.txt#L28) will work just fine with pronto-flay.
|
13
|
+
|
14
|
+
You can overwrite the default, very low mass threshold for Flay with the PRONTO_FLAY_MASS_THRESHOLD environment variable for a more sensible approach.
|
15
|
+
|
16
|
+
Severity levels for identical and similar code issues can be configured inside `.pronto.yml`:
|
17
|
+
```yaml
|
18
|
+
flay:
|
19
|
+
severity_levels:
|
20
|
+
identical: 'warning'
|
21
|
+
similar: 'warning'
|
22
|
+
```
|
data/lib/pronto/flay/version.rb
CHANGED
data/lib/pronto/flay.rb
CHANGED
@@ -3,6 +3,11 @@ require 'flay'
|
|
3
3
|
|
4
4
|
module Pronto
|
5
5
|
class Flay < Runner
|
6
|
+
DEFAULT_SEVERITY_LEVELS = {
|
7
|
+
identical: :error,
|
8
|
+
similar: :warning,
|
9
|
+
}.freeze
|
10
|
+
|
6
11
|
def run
|
7
12
|
if files.any?
|
8
13
|
flay.analyze
|
@@ -17,7 +22,11 @@ module Pronto
|
|
17
22
|
# Saving the returned Flay object at @flay so we
|
18
23
|
# can inspect it and build the messages Array.
|
19
24
|
def flay
|
20
|
-
@flay ||= ::Flay.run(
|
25
|
+
@flay ||= ::Flay.run(params)
|
26
|
+
end
|
27
|
+
|
28
|
+
def params
|
29
|
+
[*files, '-m', mass_threshold]
|
21
30
|
end
|
22
31
|
|
23
32
|
def files
|
@@ -49,13 +58,23 @@ module Pronto
|
|
49
58
|
end
|
50
59
|
|
51
60
|
def level(hash)
|
52
|
-
same?(hash) ? :
|
61
|
+
same?(hash) ? severity_levels_config[:identical] : severity_levels_config[:similar]
|
53
62
|
end
|
54
63
|
|
55
64
|
def same?(hash)
|
56
65
|
flay.identical[hash]
|
57
66
|
end
|
58
67
|
|
68
|
+
def severity_levels_config
|
69
|
+
@severity_levels_config ||= DEFAULT_SEVERITY_LEVELS.merge(custom_severity_levels_config)
|
70
|
+
.map { |k, v| [k.to_sym, v.to_sym] }
|
71
|
+
.to_h
|
72
|
+
end
|
73
|
+
|
74
|
+
def custom_severity_levels_config
|
75
|
+
Pronto::ConfigFile.new.to_h.dig('flay', 'severity_levels') || {}
|
76
|
+
end
|
77
|
+
|
59
78
|
def message(hash)
|
60
79
|
match = same?(hash) ? 'Identical' : 'Similar'
|
61
80
|
location = nodes_for(hash).map do |node|
|
@@ -80,5 +99,10 @@ module Pronto
|
|
80
99
|
def masses
|
81
100
|
flay.masses
|
82
101
|
end
|
102
|
+
|
103
|
+
def mass_threshold
|
104
|
+
@mass_threshold ||= ENV['PRONTO_FLAY_MASS_THRESHOLD'] || Pronto::ConfigFile.new.to_h.dig('flay', 'mass_threshold') || ::Flay.default_options[:mass].to_s
|
105
|
+
end
|
106
|
+
|
83
107
|
end
|
84
108
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pronto-flay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mindaugas Mozūras
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pronto
|