lib/swiftformat/plugin.rb in danger-swiftformat-0.4.0 vs lib/swiftformat/plugin.rb in danger-swiftformat-0.5.0

- old
+ new

@@ -17,10 +17,20 @@ # Additional swiftformat command line arguments # # @return [String] attr_accessor :additional_args + # Additional message to be appended the report + # + # @return [String] + attr_accessor :additional_message + + # An array of file and directory paths to exclude + # + # @return [Array<String] + attr_accessor :exclude + # Runs swiftformat # # @param [Boolean] fail_on_error # # @return [void] @@ -46,10 +56,15 @@ message << "| File | Rules |\n" message << "| ---- | ----- |\n" results[:errors].each do |error| message << "| #{error[:file].gsub(Dir.pwd + '/', '')} | #{error[:rules].join(', ')} |\n" end + + unless additional_message.nil? + message << "\n" << additional_message + end + markdown message if fail_on_error fail "SwiftFormat found issues" end @@ -59,11 +74,14 @@ # # @return [Array<String] def find_swift_files files = (git.modified_files - git.deleted_files) + git.added_files + @exclude = %w() if @exclude.nil? + files .select { |file| file.end_with?(".swift") } + .reject { |file| @exclude.any? { |glob| File.fnmatch(glob, file) } } .uniq .sort end # Constructs the SwiftFormat class