Skip to content

Script to generate shared code metrics#12091

Merged
calumgrant merged 2 commits intomainfrom
cg/shared-code-metrics
Feb 20, 2023
Merged

Script to generate shared code metrics#12091
calumgrant merged 2 commits intomainfrom
cg/shared-code-metrics

Conversation

@calumgrant
Copy link
Copy Markdown
Contributor

This script measures the amount of code sharing in the CodeQL repo, and displays the package dependencies.

Sample output:

Report on CodeQL code sharing

Generated on 2023-02-03 16:25:12.551688

Shared code by language

Language Non-shared files Non-shared lines of code Imported files Imported lines of code Shared code %
cpp 1761 121839 46 19776 13.96
csharp 1465 91281 55 23697 20.61
go 503 42928 12 9904 18.75
java 1615 97371 32 16641 14.60
javascript 1619 119286 33 16801 12.35
python 1398 86161 32 16230 15.85
ql 159 14211 8 9734 40.65
ruby 535 55640 37 18421 24.87
swift 1074 33454 15 12378 27.01
  • Non-shared files: The number of CodeQL files (.ql/.qll) that are only used within this language folder. Excludes identical-files.json that are shared between multiple languages.
  • Non-shared lines of code: The number of lines of code in the non-shared files.
  • Imported files: All CodeQL files (.ql/.qll) files that are transitively used in this language folder, either via packages or identical-files.json
  • Imported lines of code: The number of lines of code in the imported files
  • Shared code %: The proportion of imported lines / total lines (nonshared + imported).

Shared packages use by language

A package is used if it is a direct or indirect dependency, or a file shared via identical-files.json.

Asset Files Lines cpp csharp go java javascript python ql ruby swift
codeql/ruby-queries 69 2287 yes
codeql/ruby-consistency-queries 6 124 yes
codeql/ruby-all 232 48765 yes
codeql/ruby-examples 1 18 yes
codeql/ruby-tests 106 3072 yes
codeql/ruby-downgrades 121 1374 yes
codeql/ql 108 12790 yes
codeql/ql-consistency-queries 6 6 yes
codeql/ql-examples 0 0 yes
codeql/ql-tests 45 1415 yes
ql-testing-src-pack 1 8 yes
ql-testing-lib-pack 1 1 yes
ql-other-pack-thing 1 7 yes
codeql/javascript-queries 360 16712 yes
codeql/javascript-all 386 89332 yes
codeql/javascript-examples 39 804 yes
codeql/javascript-tests 778 8293 yes
codeql/javascript-experimental-atm-queries 6 155 yes
codeql/javascript-experimental-atm-lib 15 2868 yes
codeql/javascript-experimental-atm-model 0 0 yes
codeql/javascript-experimental-atm-model-building 22 827 yes
codeql/javascript-experimental-atm-tests 12 284 yes
codeql/javascript-downgrades 1 11 yes
codeql/csharp-queries 405 25086 yes
codeql/csharp-solorigate-queries 6 197 yes
codeql/csharp-solorigate-all 1 210 yes
csharp-solorigate-tests 0 0 yes
codeql-csharp-consistency-queries 6 197 yes
codeql/csharp-all 264 55499 yes
codeql/csharp-examples 28 426 yes
integration-tests 0 0 yes
codeql-csharp-tests 752 9627 yes
codeql/csharp-downgrades 3 39 yes
codeql/swift-queries 27 1831 yes
codeql/swift-all 857 29549 yes
codeql-swift-tests 167 1953 yes
codeql/swift-downgrades 3 26 yes
integration-tests-swift 20 95 yes
codeql/cpp-queries 624 33181 yes
codeql/cpp-all 364 78318 yes
codeql/cpp-examples 26 419 yes
codeql/cpp-tests 740 9803 yes
codeql/cpp-tests-cwe-190-tainted 0 0 yes
codeql/cpp-downgrades 7 118 yes
codeql/typetracking 1 860 yes
codeql/ssa 1 1169 yes yes yes yes
codeql/regex 9 3831 yes yes yes yes
codeql/util 6 695 yes yes yes yes yes yes yes yes yes
codeql/typos 1 9035 yes yes
codeql/tutorial 1 1094 yes yes yes yes yes yes yes yes
codeql/java-queries 589 30268 yes
codeql-java-consistency-queries 20 529 yes
codeql/java-all 395 58943 yes
codeql/java-examples 30 456 yes
kotlin 4 29 yes
kotlin 29 387 yes
integrationtest-default-parameter-mad-flow 1 35 yes
integrationtest-annotation-id-consistency 1 11 yes
integrationtest-kotlin-interface-inherited-default 1 36 yes
integrationtest-kotlin-java-static-fields 1 17 yes
integrationtest-gradle-kotlinx-serialization 1 5 yes
java 21 151 yes
kotlin 5 71 yes
integrationtest-custom-plugin 4 31 yes
codeql/java-tests 520 6507 yes
codeql/java-downgrades 2 30 yes
codeql/python-queries 366 17276 yes
codeql/python-consistency-queries 0 0 yes
codeql/python-all 350 59305 yes
codeql/python-examples 28 419 yes
codeql/python-tests 643 8522 yes
codeql/python-downgrades 3 129 yes
codeql-python-recorded-call-graph-metrics 8 510 yes
codeql/go-queries 93 7487 yes
codeql/go-all 198 32464 yes
codeql/go-examples 21 307 yes
legacy-libraries-go 0 0 yes
codeql/go-tests 189 2598 yes
codeql/go-downgrades 2 72 yes
codeql/suite-helpers 0 0 yes
codeql/suite-helpers 0 0 yes yes yes yes yes yes yes yes
legacy-libraries-javascript 0 0
legacy-libraries-csharp 0 0
legacy-libraries-cpp 0 0
legacy-libraries-java 0 0
legacy-libraries-python 0 0
DataFlow Java/C++/C#/Go/Python/Ruby/Swift 1 4880 yes yes yes yes yes yes yes
DataFlow Java/C++/C#/Go/Python/Ruby/Swift Common 1 1521 yes yes yes yes yes yes yes
TaintTracking::Configuration Java/C++/C#/Go/Python/Ruby/Swift 1 191 yes yes yes yes yes yes yes
DataFlow Java/C++/C#/Python/Ruby/Swift Consistency checks 1 278 yes yes yes yes yes yes
DataFlow Java/C#/Go/Ruby/Python/Swift Flow Summaries 1 1341 yes yes yes yes yes yes
SsaReadPosition Java/C# 1 65 yes yes
Model as Data Generation Java/C# - CaptureModels 1 291 yes yes
Sign Java/C# 1 280 yes yes
SignAnalysis Java/C# 1 376 yes yes
Bound Java/C# 1 78 yes yes
ModulusAnalysis Java/C# 1 281 yes yes
C++ SubBasicBlocks 1 179 yes
IR Instruction 1 2228 yes yes
IR IRBlock 1 343 yes yes
IR IRVariable 1 336 yes yes
IR IRFunction 1 59 yes yes
IR Operand 1 512 yes yes
IR IRType 1 349 yes yes
IR IRConfiguration 1 45 yes yes
IR UseSoundEscapeAnalysis 1 9 yes yes
IR IRFunctionBase 1 32 yes yes
IR Operand Tag 1 298 yes yes
IR TInstruction 1 109 yes yes
IR TIRVariable 1 23 yes yes
IR IR 1 80 yes yes
IR IRConsistency 1 548 yes yes
IR PrintIR 1 329 yes yes
IR IntegerConstant 1 236 yes yes
IR IntegerInteval 1 35 yes yes
IR IntegerPartial 1 99 yes yes
IR Overlap 1 70 yes yes
IR EdgeKind 1 139 yes yes
IR MemoryAccessKind 1 101 yes yes
IR TempVariableTag 1 17 yes yes
IR Opcode 1 1249 yes yes
IR SSAConsistency 1 2 yes yes
C++ IR InstructionImports 1 6 yes
C++ IR IRImports 1 3 yes
C++ IR IRBlockImports 1 1 yes
C++ IR IRFunctionImports 1 1 yes
C++ IR IRVariableImports 1 5 yes
C++ IR OperandImports 1 5 yes
C++ IR PrintIRImports 1 1 yes
C++ SSA SSAConstructionImports 1 6 yes
SSA AliasAnalysis 1 474 yes yes
SSA PrintAliasAnalysis 1 19 yes
C++ SSA AliasAnalysisImports 1 3 yes
C++ IR ValueNumberingImports 1 3 yes
IR SSA SimpleSSA 1 117 yes yes
IR AliasConfiguration (unaliased_ssa) 1 18 yes yes
IR SSA SSAConstruction 1 1139 yes yes
IR SSA PrintSSA 1 157 yes yes
IR ValueNumberInternal 1 314 yes yes
C++ IR ValueNumber 1 88 yes yes
C++ IR PrintValueNumbering 1 17 yes yes
C++ IR ConstantAnalysis 1 53 yes
C++ IR PrintConstantAnalysis 1 11 yes
C++ IR ReachableBlock 1 53 yes
C++ IR PrintReachableBlock 1 17 yes
C++ IR Dominance 1 22 yes
C++ IR PrintDominance 1 22 yes
C# IR InstructionImports 1 6 yes
C# IR IRImports 1 3 yes
C# IR IRBlockImports 1 1 yes
C# IR IRFunctionImports 1 1 yes
C# IR IRVariableImports 1 5 yes
C# IR OperandImports 1 5 yes
C# IR PrintIRImports 1 1 yes
C# IR ValueNumberingImports 1 3 yes
C# ControlFlowReachability 1 215 yes
C++ ExternalAPIs 1 58 yes
C++ SafeExternalAPIFunction 1 27 yes
XML 1 354 yes yes yes yes yes
DuplicationProblems.inc.qhelp 0 0
CommentedOutCodeQuery.inc.qhelp 0 0
FLinesOfCodeReferences.inc.qhelp 0 0
FCommentRatioCommon.inc.qhelp 0 0
FLinesOfCodeOverview.inc.qhelp 0 0
CommentedOutCodeMetricOverview.inc.qhelp 0 0
FLinesOfDuplicatedCodeCommon.inc.qhelp 0 0
CommentedOutCodeReferences.inc.qhelp 0 0
ThreadResourceAbuse qhelp 0 0
IDE Contextual Queries 1 22 yes yes yes yes yes
CryptoAlgorithms Python/JS/Ruby 1 101 yes yes yes
CryptoAlgorithmNames Python/JS/Ruby 1 72 yes yes yes
SensitiveDataHeuristics Python/JS 1 124 yes yes yes
CFG 1 1027 yes yes yes
TypeTracker 1 628 yes yes
AccessPathSyntax 1 182 yes yes yes yes yes yes yes
IncompleteUrlSubstringSanitization 1 61 yes yes
Concepts Python/Ruby/JS 1 156 yes yes yes
ApiGraphModels 1 703 yes yes yes
ApiGraphModelsExtensions 1 36 yes yes yes
TaintedFormatStringQuery Ruby/JS 1 27 yes yes
TaintedFormatStringCustomizations Ruby/JS 1 43 yes yes
HttpToFileAccessQuery JS/Ruby 1 25 yes yes
HttpToFileAccessCustomizations JS/Ruby 1 34 yes yes
Typo database 1 4 yes yes
Swift declarations test file 0 0
Swift statements test file 0 0
Swift expressions test file 0 0
Swift patterns test file 0 0
Swift control flow test file 0 0
IncompleteMultiCharacterSanitization JS/Ruby 1 202 yes yes
EncryptionKeySizes Python/Java 1 21 yes yes

Shared code by language pack

Package name Non-shared files Non-shared lines of code Imported files Imported lines of code Shared code %
codeql/ruby-all 232 48765 30 17665 26.59
codeql/javascript-all 386 89332 24 7006 7.27
codeql/csharp-all 264 55499 17 13354 19.39
codeql/swift-all 857 29549 9 11683 28.33
codeql/cpp-all 364 78318 58 19491 19.93
codeql/java-all 395 58943 31 16350 21.72
codeql/python-all 350 59305 26 15535 20.76
codeql/go-all 198 32464 6 9209 22.10

Shared code by package

Package name Non-shared files Non-shared lines of code Imported files Imported lines of code Shared code %
codeql/ruby-queries 69 2287 250 55615 96.05
codeql/ruby-consistency-queries 6 124 243 54859 99.77
codeql/ruby-all 232 48765 30 17665 26.59
codeql/ruby-examples 1 18 243 54859 99.97
codeql/ruby-tests 106 3072 319 57859 94.96
codeql/ruby-downgrades 121 1374 0 0 0.00
codeql/ql 108 12790 8 9734 43.22
codeql/ql-consistency-queries 6 6 115 22520 99.97
codeql/ql-examples 0 0 115 22520 100.00
codeql/ql-tests 45 1415 115 22520 94.09
ql-testing-src-pack 1 8 1 1 11.11
ql-testing-lib-pack 1 1 0 0 0.00
ql-other-pack-thing 1 7 2 9 56.25
codeql/javascript-queries 360 16712 405 104052 86.16
codeql/javascript-all 386 89332 24 7006 7.27
codeql/javascript-examples 39 804 396 94257 99.15
codeql/javascript-tests 778 8293 763 120699 93.57
codeql/javascript-experimental-atm-queries 6 155 411 97125 99.84
codeql/javascript-experimental-atm-lib 15 2868 396 94257 97.05
codeql/javascript-experimental-atm-model 0 0 0 0 0.00
codeql/javascript-experimental-atm-model-building 22 827 411 97125 99.16
codeql/javascript-experimental-atm-tests 12 284 433 97952 99.71
codeql/javascript-downgrades 1 11 0 0 0.00
codeql/csharp-queries 405 25086 313 68345 73.15
codeql/csharp-solorigate-queries 6 197 267 57972 99.66
codeql/csharp-solorigate-all 1 210 266 57762 99.64
csharp-solorigate-tests 0 0 684 83950 100.00
codeql-csharp-consistency-queries 6 197 266 57762 99.66
codeql/csharp-all 264 55499 17 13354 19.39
codeql/csharp-examples 28 426 266 57762 99.27
integration-tests 0 0 266 57762 100.00
codeql-csharp-tests 752 9627 677 83543 89.67
codeql/csharp-downgrades 3 39 0 0 0.00
codeql/swift-queries 27 1831 865 32507 94.67
codeql/swift-all 857 29549 9 11683 28.33
codeql-swift-tests 167 1953 892 34338 94.62
codeql/swift-downgrades 3 26 0 0 0.00
integration-tests-swift 20 95 859 31812 99.70
codeql/cpp-queries 624 33181 374 81361 71.03
codeql/cpp-all 364 78318 58 19491 19.93
codeql/cpp-examples 26 419 366 80581 99.48
codeql/cpp-tests 740 9803 996 114457 92.11
codeql/cpp-tests-cwe-190-tainted 0 0 996 114457 100.00
codeql/cpp-downgrades 7 118 0 0 0.00
codeql/typetracking 1 860 6 695 44.69
codeql/ssa 1 1169 0 0 0.00
codeql/regex 9 3831 0 0 0.00
codeql/util 6 695 0 0 0.00
codeql/typos 1 9035 0 0 0.00
codeql/tutorial 1 1094 0 0 0.00
codeql/java-queries 589 30268 413 65714 68.46
codeql-java-consistency-queries 20 529 412 65423 99.20
codeql/java-all 395 58943 31 16350 21.72
codeql/java-examples 30 456 412 65423 99.31
kotlin 4 29 1521 102198 99.97
kotlin 29 387 1521 102198 99.62
integrationtest-default-parameter-mad-flow 1 35 1521 102198 99.97
integrationtest-annotation-id-consistency 1 11 1521 102198 99.99
integrationtest-kotlin-interface-inherited-default 1 36 1521 102198 99.96
integrationtest-kotlin-java-static-fields 1 17 1521 102198 99.98
integrationtest-gradle-kotlinx-serialization 1 5 1521 102198 100.00
java 21 151 1521 102198 99.85
kotlin 5 71 412 65423 99.89
integrationtest-custom-plugin 4 31 412 65423 99.95
codeql/java-tests 520 6507 1001 95691 93.63
codeql/java-downgrades 2 30 0 0 0.00
codeql/python-queries 366 17276 366 64925 78.98
codeql/python-consistency-queries 0 0 360 64230 100.00
codeql/python-all 350 59305 26 15535 20.76
codeql/python-examples 28 419 360 64230 99.35
codeql/python-tests 643 8522 732 82201 90.61
codeql/python-downgrades 3 129 0 0 0.00
codeql-python-recorded-call-graph-metrics 8 510 360 64230 99.21
codeql/go-queries 93 7487 205 34253 82.06
codeql/go-all 198 32464 6 9209 22.10
codeql/go-examples 21 307 199 33558 99.09
legacy-libraries-go 0 0 0 0 0.00
codeql/go-tests 189 2598 319 42047 94.18
codeql/go-downgrades 2 72 0 0 0.00
codeql/suite-helpers 0 0 0 0 0.00
codeql/suite-helpers 0 0 0 0 0.00
legacy-libraries-javascript 0 0 0 0 0.00
legacy-libraries-csharp 0 0 0 0 0.00
legacy-libraries-cpp 0 0 0 0 0.00
legacy-libraries-java 0 0 0 0 0.00
legacy-libraries-python 0 0 0 0 0.00

@calumgrant calumgrant marked this pull request as ready for review February 8, 2023 12:47
andersfugmann
andersfugmann previously approved these changes Feb 14, 2023
Copy link
Copy Markdown
Contributor

@andersfugmann andersfugmann left a comment

Choose a reason for hiding this comment

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

LTGM. Thanks for creating this.
I have one minor comment on the PR, but feel free to ignore and merge at will.

@andersfugmann
Copy link
Copy Markdown
Contributor

I really appreciate you doing this! Its a huge help to get an overview of the current state of shared code!

I could be tempted to add an option to output in CSV (or other column based format) to allow easier view of large tables, but this is a great start!

Co-authored-by: Anders Peter Fugmann <anders@fugmann.net>
Copy link
Copy Markdown
Contributor

@andersfugmann andersfugmann left a comment

Choose a reason for hiding this comment

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

LGTM

@calumgrant calumgrant merged commit 779c236 into main Feb 20, 2023
@calumgrant calumgrant deleted the cg/shared-code-metrics branch February 20, 2023 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants