Skip to content

Commit 623068c

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: add hasProvenance predicate, remove isManuallyGenerated and isBothAutoAndManuallyGenerated
1 parent 270e38d commit 623068c

File tree

7 files changed

+20
-104
lines changed

7 files changed

+20
-104
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,10 @@ module Public {
246246
predicate isAutoGenerated() { none() }
247247

248248
/**
249-
* Holds if the summary is manually generated and not auto generated.
249+
* Holds if the summary has the given provenance where `true` is
250+
* `generated` and `false` is `manual`.
250251
*/
251-
predicate isManuallyGenerated() { none() }
252-
253-
/**
254-
* Holds if the summary is both auto generated and manually generated.
255-
*/
256-
predicate isBothAutoAndManuallyGenerated() { none() }
252+
predicate hasProvenance(boolean generated) { summaryElement(this, _, _, _, generated) }
257253
}
258254

259255
/** A callable with a flow summary stating there is no flow via the callable. */
@@ -1022,16 +1018,6 @@ module Private {
10221018
}
10231019

10241020
override predicate isAutoGenerated() { this.relevantSummaryElementGenerated(_, _, _) }
1025-
1026-
override predicate isManuallyGenerated() {
1027-
summaryElement(this, _, _, _, false) and
1028-
not summaryElement(this, _, _, _, true)
1029-
}
1030-
1031-
override predicate isBothAutoAndManuallyGenerated() {
1032-
summaryElement(this, _, _, _, true) and
1033-
summaryElement(this, _, _, _, false)
1034-
}
10351021
}
10361022

10371023
/** Holds if component `c` of specification `spec` cannot be parsed. */

go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,10 @@ module Public {
246246
predicate isAutoGenerated() { none() }
247247

248248
/**
249-
* Holds if the summary is manually generated and not auto generated.
249+
* Holds if the summary has the given provenance where `true` is
250+
* `generated` and `false` is `manual`.
250251
*/
251-
predicate isManuallyGenerated() { none() }
252-
253-
/**
254-
* Holds if the summary is both auto generated and manually generated.
255-
*/
256-
predicate isBothAutoAndManuallyGenerated() { none() }
252+
predicate hasProvenance(boolean generated) { summaryElement(this, _, _, _, generated) }
257253
}
258254

259255
/** A callable with a flow summary stating there is no flow via the callable. */
@@ -1022,16 +1018,6 @@ module Private {
10221018
}
10231019

10241020
override predicate isAutoGenerated() { this.relevantSummaryElementGenerated(_, _, _) }
1025-
1026-
override predicate isManuallyGenerated() {
1027-
summaryElement(this, _, _, _, false) and
1028-
not summaryElement(this, _, _, _, true)
1029-
}
1030-
1031-
override predicate isBothAutoAndManuallyGenerated() {
1032-
summaryElement(this, _, _, _, true) and
1033-
summaryElement(this, _, _, _, false)
1034-
}
10351021
}
10361022

10371023
/** Holds if component `c` of specification `spec` cannot be parsed. */

java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,10 @@ module Public {
246246
predicate isAutoGenerated() { none() }
247247

248248
/**
249-
* Holds if the summary is manually generated and not auto generated.
249+
* Holds if the summary has the given provenance where `true` is
250+
* `generated` and `false` is `manual`.
250251
*/
251-
predicate isManuallyGenerated() { none() }
252-
253-
/**
254-
* Holds if the summary is both auto generated and manually generated.
255-
*/
256-
predicate isBothAutoAndManuallyGenerated() { none() }
252+
predicate hasProvenance(boolean generated) { summaryElement(this, _, _, _, generated) }
257253
}
258254

259255
/** A callable with a flow summary stating there is no flow via the callable. */
@@ -1022,16 +1018,6 @@ module Private {
10221018
}
10231019

10241020
override predicate isAutoGenerated() { this.relevantSummaryElementGenerated(_, _, _) }
1025-
1026-
override predicate isManuallyGenerated() {
1027-
summaryElement(this, _, _, _, false) and
1028-
not summaryElement(this, _, _, _, true)
1029-
}
1030-
1031-
override predicate isBothAutoAndManuallyGenerated() {
1032-
summaryElement(this, _, _, _, true) and
1033-
summaryElement(this, _, _, _, false)
1034-
}
10351021
}
10361022

10371023
/** Holds if component `c` of specification `spec` cannot be parsed. */

java/ql/src/Metrics/Summaries/GeneratedVsManualCoverage.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ private float getNumMadModeledApis(string package, string provenance) {
2525
sc.isAutoGenerated() and // "auto-only"
2626
provenance = "generated"
2727
or
28-
sc.isManuallyGenerated() and // "manual-only"
28+
(sc.hasProvenance(false) and not sc.hasProvenance(true)) and // "manual-only"
2929
provenance = "manual"
3030
or
31-
sc.isBothAutoAndManuallyGenerated() and // "both"
31+
(sc.hasProvenance(false) and sc.hasProvenance(true)) and // "both"
3232
provenance = "both"
3333
)
3434
)

python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,10 @@ module Public {
246246
predicate isAutoGenerated() { none() }
247247

248248
/**
249-
* Holds if the summary is manually generated and not auto generated.
249+
* Holds if the summary has the given provenance where `true` is
250+
* `generated` and `false` is `manual`.
250251
*/
251-
predicate isManuallyGenerated() { none() }
252-
253-
/**
254-
* Holds if the summary is both auto generated and manually generated.
255-
*/
256-
predicate isBothAutoAndManuallyGenerated() { none() }
252+
predicate hasProvenance(boolean generated) { summaryElement(this, _, _, _, generated) }
257253
}
258254

259255
/** A callable with a flow summary stating there is no flow via the callable. */
@@ -1022,16 +1018,6 @@ module Private {
10221018
}
10231019

10241020
override predicate isAutoGenerated() { this.relevantSummaryElementGenerated(_, _, _) }
1025-
1026-
override predicate isManuallyGenerated() {
1027-
summaryElement(this, _, _, _, false) and
1028-
not summaryElement(this, _, _, _, true)
1029-
}
1030-
1031-
override predicate isBothAutoAndManuallyGenerated() {
1032-
summaryElement(this, _, _, _, true) and
1033-
summaryElement(this, _, _, _, false)
1034-
}
10351021
}
10361022

10371023
/** Holds if component `c` of specification `spec` cannot be parsed. */

ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,10 @@ module Public {
246246
predicate isAutoGenerated() { none() }
247247

248248
/**
249-
* Holds if the summary is manually generated and not auto generated.
249+
* Holds if the summary has the given provenance where `true` is
250+
* `generated` and `false` is `manual`.
250251
*/
251-
predicate isManuallyGenerated() { none() }
252-
253-
/**
254-
* Holds if the summary is both auto generated and manually generated.
255-
*/
256-
predicate isBothAutoAndManuallyGenerated() { none() }
252+
predicate hasProvenance(boolean generated) { summaryElement(this, _, _, _, generated) }
257253
}
258254

259255
/** A callable with a flow summary stating there is no flow via the callable. */
@@ -1022,16 +1018,6 @@ module Private {
10221018
}
10231019

10241020
override predicate isAutoGenerated() { this.relevantSummaryElementGenerated(_, _, _) }
1025-
1026-
override predicate isManuallyGenerated() {
1027-
summaryElement(this, _, _, _, false) and
1028-
not summaryElement(this, _, _, _, true)
1029-
}
1030-
1031-
override predicate isBothAutoAndManuallyGenerated() {
1032-
summaryElement(this, _, _, _, true) and
1033-
summaryElement(this, _, _, _, false)
1034-
}
10351021
}
10361022

10371023
/** Holds if component `c` of specification `spec` cannot be parsed. */

swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,10 @@ module Public {
246246
predicate isAutoGenerated() { none() }
247247

248248
/**
249-
* Holds if the summary is manually generated and not auto generated.
249+
* Holds if the summary has the given provenance where `true` is
250+
* `generated` and `false` is `manual`.
250251
*/
251-
predicate isManuallyGenerated() { none() }
252-
253-
/**
254-
* Holds if the summary is both auto generated and manually generated.
255-
*/
256-
predicate isBothAutoAndManuallyGenerated() { none() }
252+
predicate hasProvenance(boolean generated) { summaryElement(this, _, _, _, generated) }
257253
}
258254

259255
/** A callable with a flow summary stating there is no flow via the callable. */
@@ -1022,16 +1018,6 @@ module Private {
10221018
}
10231019

10241020
override predicate isAutoGenerated() { this.relevantSummaryElementGenerated(_, _, _) }
1025-
1026-
override predicate isManuallyGenerated() {
1027-
summaryElement(this, _, _, _, false) and
1028-
not summaryElement(this, _, _, _, true)
1029-
}
1030-
1031-
override predicate isBothAutoAndManuallyGenerated() {
1032-
summaryElement(this, _, _, _, true) and
1033-
summaryElement(this, _, _, _, false)
1034-
}
10351021
}
10361022

10371023
/** Holds if component `c` of specification `spec` cannot be parsed. */

0 commit comments

Comments
 (0)