Skip to content

Commit

Permalink
Add tests for inline_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
garriguv authored Nov 10, 2023
1 parent 6ed4665 commit 414279d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ certain directories or files such as `Pods`, you can use the `exclude` parameter
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 inline_mode option. Violations that are out of the diff, will be shown in danger's fail or warn section.
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
```
Expand Down
7 changes: 6 additions & 1 deletion lib/swiftformat/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ class DangerSwiftformat < Plugin
# @return [String]
attr_accessor :swiftversion

# Show issues inline in the diff instead of in a comment.
#
# @return [Boolean]
attr_accessor :inline_mode

# Runs swiftformat
#
# @param [Boolean] fail_on_error
#
# @return [void]
#
def check_format(fail_on_error: false, inline_mode: false)
def check_format(fail_on_error: false)
# Check if SwiftFormat is installed
raise "Could not find SwiftFormat executable" unless swiftformat.installed?

Expand Down
13 changes: 13 additions & 0 deletions spec/swiftformat/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,19 @@ module Danger
status = @sut.status_report
expect(status[:errors]).to be_empty
expect(status[:markdowns]).to_not be_empty
expect(status[:warnings]).to be_empty
end

it "should send inline comments when inline_mode is true" do
@sut.inline_mode = true

@sut.check_format

status = @sut.status_report
p status
expect(status[:errors]).to be_empty
expect(status[:markdowns]).to be_empty
expect(status[:warnings]).to_not be_empty
end
end
end
Expand Down

0 comments on commit 414279d

Please sign in to comment.