-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Foundation | ||
import Shared | ||
import SystemPackage | ||
|
||
final class ActionsFormatter: OutputFormatter { | ||
let configuration: Configuration | ||
lazy var currentFilePath: FilePath = { .current }() | ||
|
||
init(configuration: Configuration) { | ||
self.configuration = configuration | ||
} | ||
|
||
func format(_ results: [ScanResult]) throws -> String { | ||
guard results.count > 0 else { return "" } | ||
guard configuration.relativeResults else { throw PeripheryError.usageError("`periphery scan` must be ran with `--relative-results` when using the actions formatter")} | ||
|
||
return results.flatMap { result in | ||
describe(result, colored: false).map { (location, description) in | ||
prefix(for: location, result: result) + description | ||
} | ||
} | ||
.joined(separator: "\n") | ||
} | ||
|
||
// MARK: - Private | ||
|
||
private func prefix(for location: SourceLocation, result: ScanResult) -> String { | ||
let path = outputPath(location) | ||
let lineNum = String(location.line) | ||
let column = location.column | ||
let title = describe(result.annotation) | ||
|
||
return "::warning file=\(path),line=\(lineNum),col=\(column),title=\(title)::" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters