Skip to content

Swift: add SuccessfullyExtractedLines query#12725

Merged
redsun82 merged 2 commits intomainfrom
redsun82/swift-successfully-extracted-lines
Apr 3, 2023
Merged

Swift: add SuccessfullyExtractedLines query#12725
redsun82 merged 2 commits intomainfrom
redsun82/swift-successfully-extracted-lines

Conversation

@redsun82
Copy link
Contributor

This counts how many lines we have extracted some entity in. If we test changes in this, we can have a more fine grained look into how much we actually extract than looking at the extracted files.

This counts how many lines we have extracted some entity in. If we test
changes in this, we can have a more fine grained look into how much we
actually extract than looking at the extracted files.
@redsun82 redsun82 requested review from MathiasVP and esbena March 31, 2023 08:05
@redsun82 redsun82 requested a review from a team as a code owner March 31, 2023 08:05
@github-actions github-actions bot added the Swift label Mar 31, 2023
* @description Count all lines in source code in which something was extracted.
* @kind metric
* @id swift/diagnostics/successfully-extracted-lines
* @tags summary
Copy link
Contributor

Choose a reason for hiding this comment

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

Please confirm that * lines-of-code has been omitted here to avoid code-scanning from picking this up for the time being.

Copy link
Contributor Author

@redsun82 redsun82 Mar 31, 2023

Choose a reason for hiding this comment

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

yes, this query is different than lines-of-code queries from other languages, as

  • it will not count lines for which nothing was extracted because of any kind of problem
  • it does count comment lines
  • it will count 1 line for big things spanning multiple lines. Multiline AST-entities typically have children elements that will show up in this count, but for example multiline strings and comments will contribute only 1 line in this metric.

I think this might be confusing if it were presented as the user-facing lines-of-code, but maybe this is up for debate? For the time being I'd keep it separate

Copy link
Contributor Author

@redsun82 redsun82 Mar 31, 2023

Choose a reason for hiding this comment

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

For context: I've looked into how the C/C++ extractor extracts the data used by lines-of-code, and on each source file it just bluntly opens the file and counts the lines, matching empty and comment lines to fill in the different values of the numlines table (numcode is what is used in the lines-of-code query):

numlines(
int element_id: @sourceline ref,
int num_lines: int ref,
int num_code: int ref,
int num_comment: int ref
);

@redsun82 redsun82 merged commit 5e45377 into main Apr 3, 2023
@redsun82 redsun82 deleted the redsun82/swift-successfully-extracted-lines branch April 3, 2023 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants