Swift: Limit successfully extracted lines#21468
Merged
jketema merged 1 commit intogithub:mainfrom Mar 12, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR stabilizes the Swift SuccessfullyExtractedLines metric by only counting lines from files that belong to the analyzed source tree (excluding extractor-shipped files that can change between extractor versions).
Changes:
- Restrict the
SuccessfullyExtractedLinesquery toFiles that have arelativePath(source-directory files). - Update the expected test output accordingly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| swift/ql/src/diagnostics/SuccessfullyExtractedLines.ql | Adds a relativePath existence filter so the metric only counts source-directory files. |
| swift/ql/test/query-tests/Diagnostics/SuccessfullyExtractedLines.expected | Updates the expected numeric result to match the new filtered metric. |
You can also share your feedback on Copilot code review. Take the survey.
andersfugmann
approved these changes
Mar 12, 2026
geoffw0
approved these changes
Mar 12, 2026
Contributor
geoffw0
left a comment
There was a problem hiding this comment.
👍
Note that lines of code is also reported by swift/summary/summary-statistics. That query is intended for manual inspection not automation, so I don't think it particularly needs this change, but just so you're aware.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the last few Swift updates, we needed to update the expected test results for this query each time, because some of the files with ship with the Swift extractor get included in the count. Restrict the count to files in the source directory.
I'm not quite sure if this is how we want to address the stability of this query, but this is one possible approach. Note that that we do the same in
ql/summary/lines-of-user-codeandrb/summary/lines-of-code. A slightly different approach is taken incs/summary/lines-of-code,java/summary/lines-of-code, andjava/summary/lines-of-code-kotlin, those might offer viable alternatives.Note that there was some debate around this query when it was originally added in #12725.
Since this query is tagged as
debugas change not does not seem worth the effort.