pronto-flay 0.11.0 → 0.11.1

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: de90dcdef64f202f027ead7f152b23def7f5e7cea005245cc18716abc5690b78
4
- data.tar.gz: 5b5a3ea37e81bb221f514c3c141f917bc77436acd502de1f2213672414979236
3
+ metadata.gz: ef63495669d107a5ba8a6960b2cdd9bde37714149b41000cc60dd016c0855d52
4
+ data.tar.gz: ee6fa73a905431c80d8b44dc7d55c3c83d24c648372aaf32af2c474dc866bc6c
5
5
  SHA512:
6
- metadata.gz: a0b188cc0aff55e7451bacdc4e5cdfdad2839b43ddc035b5d2665d90c0819e5838820cb752757a5690879953354ef4d009ca9911fcafa21c0a81e27593c188b5
7
- data.tar.gz: ceba2696f8f7538187ed29d251ebff51194ba8d5d2808f6b96c23f65dbf4941f32dacff0f186f23bd659c6d403a479ad6b6e2389e009ff352cd33b2edd7045a7
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
+ ```
@@ -1,5 +1,5 @@
1
1
  module Pronto
2
2
  module FlayVersion
3
- VERSION = '0.11.0'.freeze
3
+ VERSION = '0.11.1'.freeze
4
4
  end
5
5
  end
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(files)
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) ? :error : :warning
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.0
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-02-01 00:00:00.000000000 Z
11
+ date: 2021-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pronto