Skip to content

Commit

Permalink
fix: UpdateComplexity is now only called if the class has changed, or…
Browse files Browse the repository at this point in the history
… is new
  • Loading branch information
isc-cge committed Aug 14, 2024
1 parent c423ebe commit c163dbe
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cls/TestCoverage/Data/CodeUnit.cls
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ Property LineIsPython As array Of %Boolean;
/// Set to true if this class/routine is generated
Property Generated As %Boolean [ InitialExpression = 0 ];

///
/// If the CodeUnit has changed since we last updated it, used to see if we need to call UpdateComplexity
Property OutdatedComplexity As %Boolean [ InitialExpression = 1 ];

/// Methods, branches, etc. within this unit of code.
Relationship SubUnits As TestCoverage.Data.CodeSubUnit [ Cardinality = children, Inverse = Parent ];

Expand Down Expand Up @@ -87,6 +89,9 @@ ClassMethod GetCurrentByName(pInternalName As %String, pSourceNamespace As %Stri
If (tUpdatedHash '= tKnownHash) {
//Clear out old data and flag the need for an update.
Set tNeedsUpdate = 1
If $IsObject($Get(tMapToUnit)) {
set tMapToUnit.OutdatedComplexity = 1
}
&sql(delete from TestCoverage_Data.CodeUnitMap where ToHash = :tKnownHash)
If (SQLCODE < 0) {
Throw ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE,%msg)
Expand Down Expand Up @@ -521,9 +526,10 @@ Method UpdateSourceMap(pSourceNamespace As %String, ByRef pCache) As %Status
}
}

// Update cyclomatic complexity for methods in the linked class
// Update cyclomatic complexity for methods in the linked class if we don't already have the newest version
Set tClass = $Order(tCodeUnits("CLS",""),1,tClassCodeUnit)
If $IsObject($Get(tClassCodeUnit)) {
If ($IsObject($Get(tClassCodeUnit)) && (tClassCodeUnit.OutdatedComplexity)){
set tClassCodeUnit.OutdatedComplexity = 0
$$$ThrowOnError(tClassCodeUnit.UpdateComplexity())
}
} Catch e {
Expand Down Expand Up @@ -690,6 +696,9 @@ Storage Default
<Value name="5">
<Value>Generated</Value>
</Value>
<Value name="6">
<Value>OutdatedComplexity</Value>
</Value>
</Data>
<Data name="LineIsPython">
<Attribute>LineIsPython</Attribute>
Expand Down

0 comments on commit c163dbe

Please sign in to comment.