Class: CodeFormatter::SwiftLintFormatter

Inherits:
Formatter
  • Object
show all
Defined in:
lib/code_formatter/formatters/swift_lint_formatter.rb

Instance Attribute Summary

Attributes inherited from Formatter

#config, #path

Instance Method Summary collapse

Methods inherited from Formatter

#initialize

Constructor Details

This class inherits a constructor from CodeFormatter::Formatter

Instance Method Details

#formatObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/code_formatter/formatters/swift_lint_formatter.rb', line 7

def format
  unless Environment.exist? 'swiftlint'
    warn "warning: [swiftlint] not found (to install it run 'brew install swiftlint')"
    return
  end

  create_config do |file|
    system("swiftlint autocorrect --path #{path} --config #{file.path}")
    system("swiftlint --path #{path} --config #{file.path}")
  end
end