Skip to content

Release Update#16

Open
gsfbuildbot wants to merge 6 commits intomasterfrom
development
Open

Release Update#16
gsfbuildbot wants to merge 6 commits intomasterfrom
development

Conversation

@gsfbuildbot
Copy link
Contributor

This PR was Generated by a release of openHistorian

const double Omega = 2.0 * Math.PI * nominalFreq;
int totalSamples = (int)(sampleRate / nominalFreq * 50);
long samplePeriodNs = (long)(1e9 / sampleRate);
double omega = 2.0 * Math.PI * nominalFreq;

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This assignment to
omega
is useless, since its value is never read.

Copilot Autofix

AI 3 days ago

In general, when a local variable is assigned but never read, either the variable should be removed (if it is genuinely unused) or the code should be corrected to actually use it (if it was intended to participate in the logic). Here, omega is the angular frequency derived from nominalFreq. Since no later code reads omega in the provided method, the best fix that preserves existing behavior is to remove the declaration/assignment of omega. This eliminates the useless assignment without changing any program logic, because nothing depended on omega.

Concretely, in src/Gemstone.PhasorProtocols/SelCWS/RollingPhaseEstimationTest.cs, within TestNominalFrequency(), delete the line that declares and assigns omega (line 56). No additional imports, methods, or definitions are needed, and no other lines need to change.

Suggested changeset 1
src/Gemstone.PhasorProtocols/SelCWS/RollingPhaseEstimationTest.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/Gemstone.PhasorProtocols/SelCWS/RollingPhaseEstimationTest.cs b/src/Gemstone.PhasorProtocols/SelCWS/RollingPhaseEstimationTest.cs
--- a/src/Gemstone.PhasorProtocols/SelCWS/RollingPhaseEstimationTest.cs
+++ b/src/Gemstone.PhasorProtocols/SelCWS/RollingPhaseEstimationTest.cs
@@ -53,7 +53,6 @@
         // Generate samples for 50 cycles worth of data
         int totalSamples = (int)(sampleRate / nominalFreq * 50);
         long samplePeriodNs = (long)(1e9 / sampleRate);
-        double omega = 2.0 * Math.PI * nominalFreq;
         long epochNs = 0;
 
         double lastFrequency = 0;
EOF
@@ -53,7 +53,6 @@
// Generate samples for 50 cycles worth of data
int totalSamples = (int)(sampleRate / nominalFreq * 50);
long samplePeriodNs = (long)(1e9 / sampleRate);
double omega = 2.0 * Math.PI * nominalFreq;
long epochNs = 0;

double lastFrequency = 0;
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +649 to +652
if (Math.Abs(sincArg) < 1e-15D)
sincVal = 1.0D;
else
sincVal = Math.Sin(sincArg) / sincArg;

Check notice

Code scanning / CodeQL

Missed ternary opportunity Note

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.

Copilot Autofix

AI 3 days ago

To fix the issue, replace the if/else block that only assigns to sincVal with a single assignment using the conditional (?:) operator. This will condense the logic into one line, better expressing that sincVal is chosen between two values based solely on the condition, without changing functionality.

Concretely, in src/Gemstone.PhasorProtocols/SelCWS/RollingPhaseEstimator.cs, in the M-class filter section inside the for (int i = 0; i <= N; i++) loop (around lines 670–675), remove the multi-line if (Math.Abs(sincArg) < 1e-15D) ... else ... that assigns to sincVal, and replace it with a single line:

double sincVal = Math.Abs(sincArg) < 1e-15D ? 1.0D : Math.Sin(sincArg) / sincArg;

No new methods, imports, or definitions are required; this is a pure refactor of existing logic, keeping the exact same condition and branch expressions.

Suggested changeset 1
src/Gemstone.PhasorProtocols/SelCWS/RollingPhaseEstimator.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/Gemstone.PhasorProtocols/SelCWS/RollingPhaseEstimator.cs b/src/Gemstone.PhasorProtocols/SelCWS/RollingPhaseEstimator.cs
--- a/src/Gemstone.PhasorProtocols/SelCWS/RollingPhaseEstimator.cs
+++ b/src/Gemstone.PhasorProtocols/SelCWS/RollingPhaseEstimator.cs
@@ -667,13 +667,8 @@
                 double k = i - N / 2.0D;
                 double sincArg = TwoPI * (2.0D * Ffr) / fs * k;
 
-                double sincVal;
+                double sincVal = Math.Abs(sincArg) < 1e-15D ? 1.0D : Math.Sin(sincArg) / sincArg;
 
-                if (Math.Abs(sincArg) < 1e-15D)
-                    sincVal = 1.0D;
-                else
-                    sincVal = Math.Sin(sincArg) / sincArg;
-
                 w[i] = sincVal * hamming[i];
             }
         }
EOF
@@ -667,13 +667,8 @@
double k = i - N / 2.0D;
double sincArg = TwoPI * (2.0D * Ffr) / fs * k;

double sincVal;
double sincVal = Math.Abs(sincArg) < 1e-15D ? 1.0D : Math.Sin(sincArg) / sincArg;

if (Math.Abs(sincArg) < 1e-15D)
sincVal = 1.0D;
else
sincVal = Math.Sin(sincArg) / sincArg;

w[i] = sincVal * hamming[i];
}
}
Copilot is powered by AI and may make mistakes. Always verify output.
…udes and m_publishAngles (which already have the nominal rotation removed)
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