Skip to content

Swift: Limit successfully extracted lines#21468

Merged
jketema merged 1 commit intogithub:mainfrom
jketema:jketema/swift-lines
Mar 12, 2026
Merged

Swift: Limit successfully extracted lines#21468
jketema merged 1 commit intogithub:mainfrom
jketema:jketema/swift-lines

Conversation

@jketema
Copy link
Contributor

@jketema jketema commented Mar 12, 2026

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-code and rb/summary/lines-of-code. A slightly different approach is taken in cs/summary/lines-of-code, java/summary/lines-of-code, and java/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 debug as change not does not seem worth the effort.

@github-actions github-actions bot added the Swift label Mar 12, 2026
@jketema jketema marked this pull request as ready for review March 12, 2026 15:24
@jketema jketema requested a review from a team as a code owner March 12, 2026 15:24
Copilot AI review requested due to automatic review settings March 12, 2026 15:24
@jketema jketema added the no-change-note-required This PR does not need a change note label Mar 12, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SuccessfullyExtractedLines query to Files that have a relativePath (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.

Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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.

@jketema jketema merged commit b758732 into github:main Mar 12, 2026
33 of 34 checks passed
@jketema jketema deleted the jketema/swift-lines branch March 12, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Swift

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants