Class: Fastlane::Actions::SwiftlintAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::SwiftlintAction
- Defined in:
- lib/fastlane/actions/swiftlint.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .return_value ⇒ Object
Class Method Summary collapse
Methods inherited from Fastlane::Action
action_name, author, sh, step_text
Class Method Details
.authors ⇒ Object
75 76 77 |
# File 'lib/fastlane/actions/swiftlint.rb', line 75 def self. ["KrauseFx"] end |
.available_options ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/fastlane/actions/swiftlint.rb', line 44 def self. [ FastlaneCore::ConfigItem.new(key: :mode, description: "SwiftLint mode: :lint (default) or :autocorrect; default is :lint", is_string: false, default_value: :lint, optional: true), FastlaneCore::ConfigItem.new(key: :output_file, description: 'Path to output SwiftLint result', optional: true), FastlaneCore::ConfigItem.new(key: :config_file, description: 'Custom configuration file of SwiftLint', optional: true), FastlaneCore::ConfigItem.new(key: :strict, description: 'Fail on warnings? (true/false)', default_value: false, is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :files, description: 'List of files to process', is_string: false, optional: true) ] end |
.description ⇒ Object
37 38 39 |
# File 'lib/fastlane/actions/swiftlint.rb', line 37 def self.description "Run swift code validation using SwiftLint" end |
.details ⇒ Object
41 42 |
# File 'lib/fastlane/actions/swiftlint.rb', line 41 def self.details end |
.is_supported?(platform) ⇒ Boolean
79 80 81 |
# File 'lib/fastlane/actions/swiftlint.rb', line 79 def self.is_supported?(platform) [:ios, :mac].include?(platform) end |
.output ⇒ Object
69 70 |
# File 'lib/fastlane/actions/swiftlint.rb', line 69 def self.output end |
.return_value ⇒ Object
72 73 |
# File 'lib/fastlane/actions/swiftlint.rb', line 72 def self.return_value end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fastlane/actions/swiftlint.rb', line 4 def self.run(params) if `which swiftlint`.to_s.length == 0 and !Helper.test? raise "You have to install swiftlint using `brew install swiftlint`".red end version = Gem::Version.new(Helper.test? ? '0.0.0' : `swiftlint version`.chomp) if params[:mode] == :autocorrect and version < Gem::Version.new('0.5.0') and !Helper.test? raise "Your version of swiftlint (#{version}) does not support autocorrect mode.\nUpdate swiftlint using `brew update && brew upgrade swiftlint`".red end command = "swiftlint #{params[:mode]}" command << " --strict" if params[:strict] command << " --config #{params[:config_file].shellescape}" if params[:config_file] if params[:files] if version < Gem::Version.new('0.5.1') and !Helper.test? raise "Your version of swiftlint (#{version}) does not support list of files as input.\nUpdate swiftlint using `brew update && brew upgrade swiftlint`".red end files = params[:files].map.with_index(0) { |f, i| "SCRIPT_INPUT_FILE_#{i}=#{f.shellescape}" }.join(" ") command = command.prepend("SCRIPT_INPUT_FILE_COUNT=#{params[:files].count} #{files} ") command << " --use-script-input-files" end command << " > #{params[:output_file].shellescape}" if params[:output_file] Actions.sh(command) end |