Skip to content

Commit

Permalink
Add a metric to record how many interface fields are resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
ihji committed Sep 28, 2024
1 parent 724cfcc commit 95af1af
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 10 deletions.
9 changes: 9 additions & 0 deletions semgrep_metrics.atd
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,22 @@ type pro_features = {
* Since semgrep 1.46
*)
?diffDepth <ocaml mutable>: int option;

(* The number of scanned files per language for inter-file diff scan mode.
* This number represents the count of changed files and their limited
* dependencies.
* Since semgrep 1.70
*)
?numInterfileDiffScanned <ocaml mutable>: (string (* lang *) * int) list
<json repr="object"> option;

(* The number of interface fields resolved during the Naming_SAST phases.
* This is the total count from the naming resolution of all field accesses
* in the input source code.
* Since semgrep 1.91
*)
?numInterfaceVarResolved <ocaml mutable>: int option;
?numInterfaceMethodResolved <ocaml mutable>: int option;
}

(* Since v1.55.0 *)
Expand Down
8 changes: 8 additions & 0 deletions semgrep_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,17 @@ class ProFeatures:

diffDepth: Optional[int] = None
numInterfileDiffScanned: Optional[List[Tuple[str, int]]] = None
numInterfaceVarResolved: Optional[int] = None
numInterfaceMethodResolved: Optional[int] = None

@classmethod
def from_json(cls, x: Any) -> 'ProFeatures':
if isinstance(x, dict):
return cls(
diffDepth=_atd_read_int(x['diffDepth']) if 'diffDepth' in x else None,
numInterfileDiffScanned=_atd_read_assoc_object_into_list(_atd_read_int)(x['numInterfileDiffScanned']) if 'numInterfileDiffScanned' in x else None,
numInterfaceVarResolved=_atd_read_int(x['numInterfaceVarResolved']) if 'numInterfaceVarResolved' in x else None,
numInterfaceMethodResolved=_atd_read_int(x['numInterfaceMethodResolved']) if 'numInterfaceMethodResolved' in x else None,
)
else:
_atd_bad_json('ProFeatures', x)
Expand All @@ -428,6 +432,10 @@ def to_json(self) -> Any:
res['diffDepth'] = _atd_write_int(self.diffDepth)
if self.numInterfileDiffScanned is not None:
res['numInterfileDiffScanned'] = _atd_write_assoc_list_to_object(_atd_write_int)(self.numInterfileDiffScanned)
if self.numInterfaceVarResolved is not None:
res['numInterfaceVarResolved'] = _atd_write_int(self.numInterfaceVarResolved)
if self.numInterfaceMethodResolved is not None:
res['numInterfaceMethodResolved'] = _atd_write_int(self.numInterfaceMethodResolved)
return res

@classmethod
Expand Down
3 changes: 3 additions & 0 deletions semgrep_output_v1.atd
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,9 @@ type cli_output_extra = {

(* EXPERIMENTAL: since: 1.37.0 *)
~skipped_rules: skipped_rule list;

(* EXPERIMENTAL: since: 1.91.0 *)
?extra_extra: raw_json option;
}

(*****************************************************************************)
Expand Down
9 changes: 6 additions & 3 deletions semgrep_output_v1.jsonschema

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion semgrep_output_v1.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions semgrep_output_v1.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions semgrep_output_v1.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 95af1af

Please sign in to comment.