Add an identifier to Reporters
This request adds an identifier to the location object so that consumers of the SwiftLint results who are not accessing via an IDE can quickly determine and report out about where the violation occurred.
This PR gets an identifier from the AST and adds it to the Location information when processing the FunctionBodyLengthRule. This identifier is reported out in the following reporters currently:
-
JSONReporter -
CSVReporter -
MarkdownReporter -
GitLabJUnitReporter
| 1 Error | |
|---|---|
| :no_entry_sign: | Please rebase to get rid of the merge commits in this PR |
| 12 Messages | |
|---|---|
| :book: | Linting Aerial with this PR took 0.95s vs 0.95s on master (0% slower) |
| :book: | Linting Alamofire with this PR took 1.0s vs 1.01s on master (0% faster) |
| :book: | Linting Firefox with this PR took 3.3s vs 3.33s on master (0% faster) |
| :book: | Linting Kickstarter with this PR took 6.65s vs 6.72s on master (1% faster) |
| :book: | Linting Moya with this PR took 4.34s vs 4.35s on master (0% faster) |
| :book: | Linting Nimble with this PR took 0.39s vs 0.39s on master (0% slower) |
| :book: | Linting Quick with this PR took 0.18s vs 0.18s on master (0% slower) |
| :book: | Linting Realm with this PR took 6.47s vs 6.48s on master (0% faster) |
| :book: | Linting SourceKitten with this PR took 0.31s vs 0.31s on master (0% slower) |
| :book: | Linting Sourcery with this PR took 1.88s vs 1.88s on master (0% slower) |
| :book: | Linting Swift with this PR took 2.95s vs 2.94s on master (0% slower) |
| :book: | Linting WordPress with this PR took 6.65s vs 6.66s on master (0% faster) |
Generated by :no_entry_sign: Danger
Just updated to take in other accepted changes and get the build passing. Any chance this could be reviewed for inclusion in the next release of SwiftLint?
@jpsim Just wondering what I can do to help get this added to the next release.
@walterg2 looks like the identifiers are always null in the reporters?
@jpsim Apologies. It looks like a merge removed that addition to the ReporterTests. This has been added back in.
This is a generally useful feature for all rules, not just the function body length rule. Is there a way all rules that point to an identifier could benefit from this? Otherwise this will feel like an incomplete feature.
@jpsim I can take a look to see about implementing it for other rules as well. I shied away from this as an initial implementation due to the dynamic nature of how tests are currently built for other rules versus the Function Body rule.
If we do this it needs to work with all rules where this applies. Not all violations point to a specific identifier though, and not all identifiers are methods.