lib/swiftformat/plugin.rb in danger-swiftformat-0.7.0 vs lib/swiftformat/plugin.rb in danger-swiftformat-0.8.0

- old
+ new

@@ -24,13 +24,18 @@ # @return [String] attr_accessor :additional_message # An array of file and directory paths to exclude # - # @return [Array<String] + # @return [Array<String>] attr_accessor :exclude + # The project Swift version + # + # @return [String] + attr_accessor :swiftversion + # Runs swiftformat # # @param [Boolean] fail_on_error # # @return [void] @@ -44,20 +49,20 @@ # Stop processing if there are no swift files return if swift_files.empty? # Run swiftformat - results = swiftformat.check_format(swift_files, additional_args) + results = swiftformat.check_format(swift_files, additional_args, swiftversion) # Stop processing if the errors array is empty return if results[:errors].empty? # Process the errors message = "### SwiftFormat found issues:\n\n" message << "| File | Rules |\n" message << "| ---- | ----- |\n" results[:errors].each do |error| - message << "| #{error[:file].gsub(Dir.pwd + '/', '')} | #{error[:rules].join(', ')} |\n" + message << "| #{error[:file].gsub("#{Dir.pwd}/", '')} | #{error[:rules].join(', ')} |\n" end unless additional_message.nil? message << "\n" << additional_message end