Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/garriguv/danger-ruby-swiftformat
A danger plugin to check Swift formatting using SwiftFormat.
https://github.com/garriguv/danger-ruby-swiftformat
Last synced: 13 days ago
JSON representation
A danger plugin to check Swift formatting using SwiftFormat.
- Host: GitHub
- URL: https://github.com/garriguv/danger-ruby-swiftformat
- Owner: garriguv
- License: mit
- Created: 2017-12-20T16:12:46.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-05-16T21:49:26.000Z (6 months ago)
- Last Synced: 2024-10-16T04:20:42.471Z (29 days ago)
- Language: Ruby
- Homepage:
- Size: 105 KB
- Stars: 39
- Watchers: 4
- Forks: 15
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-danger - danger-ruby-swiftformat - A danger plugin to check Swift formatting using SwiftFormat. (Plugins / Ruby (danger))
README
# danger-swiftformat [![Gem Version](https://badge.fury.io/rb/danger-swiftformat.svg)](https://rubygems.org/gems/danger-swiftformat)
A [Danger] plugin to check Swift formatting using [SwiftFormat].
This plugin is heavily inspired by [danger-swiftlint].
## Installation
Add this line to your Gemfile:
```ruby
gem 'danger-swiftformat'
```[SwiftFormat] also needs to be installed before you run Danger.
## Usage
Add this to your `Dangerfile`
```ruby
swiftformat.check_format
```By default, danger-swiftformat will check added and modified files.
## Options and parameters
If you want errors to fail Danger, you can use the `fail_on_error` option:
```ruby
swiftformat.check_format(fail_on_error: true)
```You can specify the `swiftformat` binary using the `binary_path` parameter:
```ruby
swiftformat.binary_path = "/path/to/swiftformat"
```You can specify the Swift version of your project using the `swiftversion` parametter:
```ruby
swiftformat.swiftversion = "5"
```You can specify additional `swiftformat` arguments using the `additional_args` parameter:
```ruby
swiftformat.additional_args = "--indent tab --self insert"
```You can specify additional message (e.g. how to fix format issue) for danger comment using the `additional_message` parameter:
```ruby
swiftformat.additional_message = "your additional message for contributor"
```By default, `danger-swiftformat` will run on any modified or created file ending in `.swift`. If you'd like to exclude
certain directories or files such as `Pods`, you can use the `exclude` parameter:```ruby
swiftformat.exclude = %w(Pods/** Carthage/** Sources/Nope.swift **/*_autogenerated.swift)
```If you want the format results shows in the diff instead of a comment, you can use the `inline_mode` option. Violations that are out of the diff will be shown in danger's fail or warn section:
```ruby
swiftformat.inline_mode = true
```The `exclude` option takes an array of glob patterns; you can find additional documentation on the patterns
[here](https://ruby-doc.org/core-2.6.3/File.html#method-c-fnmatch).## Development
1. Clone this repo
2. Run `bundle install` to setup dependencies.
3. Run `bundle exec rake spec` to run the tests.
4. Use `bundle exec guard` to automatically have tests run as you make changes.
5. Make your changes.## Releasing a new version
Use the release.sh script:
```shell
./scripts/release.sh
```Then bump the gem to the next patch version.
[Danger]: https://danger.systems/ruby/
[SwiftFormat]: https://github.com/nicklockwood/SwiftFormat
[danger-swiftlint]: https://github.com/ashfurrow/danger-ruby-swiftlint