fastlane-plugin-lizard 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: 9de970de855b2210fbf9fb92295f5702084531ae
4
- data.tar.gz: 0bce82b9a9c562a7c1b8d2abb09bdcbe5bbcc594
3
+ metadata.gz: d021d0376a3f95325bb7091c80ddcb8212e8763b
4
+ data.tar.gz: '0830d4bd674dba3ecb576c3f1fb5f24f6b04ea6c'
5
5
  SHA512:
6
- metadata.gz: bba85d449d509527f062e79bf433754eed0a803207ece49c12b64c404d557eb54ad4afce9aa9c331f8ea9e7acae1a61c4478c30c3bb4611ab8e2ce955ffc5a44
7
- data.tar.gz: 8cca9c3904dc1f04e520cc83eb9113416d1e0d307460f2af75aed854c37327e8c99029c84135aa2531176a37b2705a3d0614236c2a11af6f8167bde9e6fc27ca
6
+ metadata.gz: 066f6e46bd86d04f569576a517ca4986edf6dfe7270067f2625fe7f3ea40bce0d25e35f8dd6bc29a319fc9b1ac3e20f3583793b6d45836b69b621cd306cc2fd3
7
+ data.tar.gz: 69cf3138e8ace4ebbf2b5f64da973ef5a752f55456c03cf65c5bd92099dfcc2c2df0872da2bf555cc8d42142b61573755adda082362c3bafac2ddd938b11343e
@@ -2,10 +2,14 @@ module Fastlane
2
2
  module Actions
3
3
  class LizardAction < Action
4
4
  def self.run(params)
5
- if `which lizard`.to_s.empty?
5
+ if params[:executable].nil? && `which lizard`.to_s.empty?
6
6
  UI.user_error!("You have to install lizard using `[sudo] pip install lizard` or specify the executable path with the `:executable` option.")
7
7
  end
8
8
 
9
+ if params[:executable] && !File.exist?(params[:executable])
10
+ UI.user_error!("The custom executable at '#{params[:executable]}' does not exist.")
11
+ end
12
+
9
13
  command = forming_command(params)
10
14
 
11
15
  if params[:show_warnings]
@@ -24,8 +28,7 @@ module Fastlane
24
28
  command = []
25
29
  command << 'lizard' unless params[:executable]
26
30
  command << "python #{params[:executable]}" if params[:executable]
27
- command << params[:source_folder].to_s if params[:source_folder]
28
- command << "-l #{params[:language]}" if params[:language]
31
+ command << params[:language].split(",").map { |l| "-l #{l.strip}" }.join(" ") if params[:language]
29
32
  command << "--#{params[:export_type]}" if params[:export_type]
30
33
  command << "-C #{params[:ccn]}" if params[:ccn] # stands for cyclomatic complexity number
31
34
  command << "-L #{params[:length]}" if params[:length]
@@ -36,6 +39,7 @@ module Fastlane
36
39
  command << "-E #{params[:extensions]}" if params[:extensions]
37
40
  command << "-s #{params[:sorting]}" if params[:sorting]
38
41
  command << "-W #{params[:whitelist]}" if params[:whitelist]
42
+ command << params[:source_folder].to_s if params[:source_folder]
39
43
  command << "> #{params[:report_file].shellescape}" if params[:report_file]
40
44
 
41
45
  return command
@@ -81,7 +85,7 @@ module Fastlane
81
85
  optional: true),
82
86
  FastlaneCore::ConfigItem.new(key: :language,
83
87
  env_name: "FL_LIZARD_LANGUAGE",
84
- description: "List the programming languages you want to analyze",
88
+ description: "List the programming languages you want to analyze, e.g. 'swift,objectivec'",
85
89
  default_value: "swift",
86
90
  optional: true),
87
91
  FastlaneCore::ConfigItem.new(key: :export_type,
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Lizard
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-lizard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moses Liao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-12 00:00:00.000000000 Z
11
+ date: 2018-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -132,7 +132,6 @@ files:
132
132
  - README.md
133
133
  - lib/fastlane/plugin/lizard.rb
134
134
  - lib/fastlane/plugin/lizard/actions/lizard_action.rb
135
- - lib/fastlane/plugin/lizard/actions/swiftlint_example.rb
136
135
  - lib/fastlane/plugin/lizard/helper/lizard_helper.rb
137
136
  - lib/fastlane/plugin/lizard/version.rb
138
137
  homepage: https://github.com/liaogz82/fastlane-plugin-lizard
@@ -1,166 +0,0 @@
1
- module Fastlane
2
- module Actions
3
- class SwiftlintAction < Action
4
- def self.run(params)
5
- if `which swiftlint`.to_s.length == 0 && params[:executable].nil? && !Helper.test?
6
- UI.user_error!("You have to install swiftlint using `brew install swiftlint` or specify the executable path with the `:executable` option.")
7
- end
8
-
9
- version = swiftlint_version(executable: params[:executable])
10
- if params[:mode] == :autocorrect and version < Gem::Version.new('0.5.0') and !Helper.test?
11
- UI.user_error!("Your version of swiftlint (#{version}) does not support autocorrect mode.\nUpdate swiftlint using `brew update && brew upgrade swiftlint`")
12
- end
13
-
14
- command = (params[:executable] || "swiftlint").dup
15
- command << " #{params[:mode]}"
16
- command << supported_option_switch(params, :strict, "0.9.2", true)
17
- command << " --config #{params[:config_file].shellescape}" if params[:config_file]
18
- command << " --reporter #{params[:reporter]}" if params[:reporter]
19
- command << supported_option_switch(params, :quiet, "0.9.0", true)
20
-
21
- if params[:files]
22
- if version < Gem::Version.new('0.5.1')
23
- UI.user_error!("Your version of swiftlint (#{version}) does not support list of files as input.\nUpdate swiftlint using `brew update && brew upgrade swiftlint`")
24
- end
25
-
26
- files = params[:files].map.with_index(0) { |f, i| "SCRIPT_INPUT_FILE_#{i}=#{f.shellescape}" }.join(" ")
27
- command = command.prepend("SCRIPT_INPUT_FILE_COUNT=#{params[:files].count} #{files} ")
28
- command << " --use-script-input-files"
29
- end
30
-
31
- command << " > #{params[:output_file].shellescape}" if params[:output_file]
32
-
33
- begin
34
- Actions.sh(command)
35
- rescue
36
- handle_swiftlint_error(params[:ignore_exit_status], $?.exitstatus)
37
- end
38
- end
39
-
40
- # Get current SwiftLint version
41
- def self.swiftlint_version(executable: nil)
42
- binary = executable || 'swiftlint'
43
- Gem::Version.new(`#{binary} version`.chomp)
44
- end
45
-
46
- # Return "--option" switch if option is on and current SwiftLint version is greater or equal than min version.
47
- # Return "" otherwise.
48
- def self.supported_option_switch(params, option, min_version, can_ignore = false)
49
- return "" unless params[option]
50
- version = swiftlint_version(executable: params[:executable])
51
- if version < Gem::Version.new(min_version)
52
- message = "Your version of swiftlint (#{version}) does not support '--#{option}' option.\nUpdate swiftlint to #{min_version} or above using `brew update && brew upgrade swiftlint`"
53
- message += "\nThe option will be ignored." if can_ignore
54
- can_ignore ? UI.important(message) : UI.user_error!(message)
55
- ""
56
- else
57
- " --#{option}"
58
- end
59
- end
60
-
61
- #####################################################
62
- # @!group Documentation
63
- #####################################################
64
-
65
- def self.description
66
- "Run swift code validation using Lizard"
67
- end
68
-
69
- def self.details
70
- end
71
-
72
- def self.available_options
73
- [
74
- FastlaneCore::ConfigItem.new(key: :mode,
75
- description: "SwiftLint mode: :lint or :autocorrect",
76
- is_string: false,
77
- default_value: :lint,
78
- optional: true),
79
- FastlaneCore::ConfigItem.new(key: :output_file,
80
- description: 'Path to output SwiftLint result',
81
- optional: true),
82
- FastlaneCore::ConfigItem.new(key: :config_file,
83
- description: 'Custom configuration file of SwiftLint',
84
- optional: true),
85
- FastlaneCore::ConfigItem.new(key: :strict,
86
- description: 'Fail on warnings? (true/false)',
87
- default_value: false,
88
- is_string: false,
89
- optional: true),
90
- FastlaneCore::ConfigItem.new(key: :files,
91
- description: 'List of files to process',
92
- is_string: false,
93
- optional: true),
94
- FastlaneCore::ConfigItem.new(key: :ignore_exit_status,
95
- description: "Ignore the exit status of the SwiftLint command, so that serious violations \
96
- don't fail the build (true/false)",
97
- default_value: false,
98
- is_string: false,
99
- optional: true),
100
- FastlaneCore::ConfigItem.new(key: :reporter,
101
- description: 'Choose output reporter',
102
- is_string: true,
103
- optional: true),
104
- FastlaneCore::ConfigItem.new(key: :quiet,
105
- description: "Don't print status logs like 'Linting <file>' & 'Done linting'",
106
- default_value: false,
107
- is_string: false,
108
- optional: true),
109
- FastlaneCore::ConfigItem.new(key: :executable,
110
- description: "Path to the `swiftlint` executable on your machine",
111
- is_string: true,
112
- optional: true)
113
- ]
114
- end
115
-
116
- def self.output
117
- end
118
-
119
- def self.return_value
120
- end
121
-
122
- def self.authors
123
- ["KrauseFx"]
124
- end
125
-
126
- def self.is_supported?(platform)
127
- [:ios, :mac].include?(platform)
128
- end
129
-
130
- def self.example_code
131
- [
132
- 'swiftlint(
133
- mode: :lint, # SwiftLint mode: :lint (default) or :autocorrect
134
- output_file: "swiftlint.result.json", # The path of the output file (optional)
135
- config_file: ".swiftlint-ci.yml", # The path of the configuration file (optional)
136
- files: [ # List of files to process (optional)
137
- "AppDelegate.swift",
138
- "path/to/project/Model.swift"
139
- ],
140
- ignore_exit_status: true # Allow fastlane to continue even if SwiftLint returns a non-zero exit status
141
- )'
142
- ]
143
- end
144
-
145
- def self.category
146
- :testing
147
- end
148
-
149
- def self.handle_swiftlint_error(ignore_exit_status, exit_status)
150
- if ignore_exit_status
151
- failure_suffix = 'which would normally fail the build.'
152
- secondary_message = 'fastlane will continue because the `ignore_exit_status` option was used! 🙈'
153
- else
154
- failure_suffix = 'which represents a failure.'
155
- secondary_message = 'If you want fastlane to continue anyway, use the `ignore_exit_status` option. 🙈'
156
- end
157
-
158
- UI.important("")
159
- UI.important("SwiftLint finished with exit code #{exit_status}, #{failure_suffix}")
160
- UI.important(secondary_message)
161
- UI.important("")
162
- UI.user_error!("SwiftLint finished with errors (exit code: #{exit_status})") unless ignore_exit_status
163
- end
164
- end
165
- end
166
- end