djmaxus / matlab-repo-init

Quickstart your public MATLAB repository
https://djmaxus.github.io/matlab-repo-init/
Apache License 2.0
1 stars 1 forks source link

Suggestion: Also flag Matlab warnings with CI #19

Open alexdewar opened 5 days ago

alexdewar commented 5 days ago

While there is a GitHub Action to check for errors in code, it is not currently checking for warnings, which could be useful. The only caveat is that if Matlab produces a lot of unhelpful warnings, failing the CI for every single one is probably not that useful. I haven't actually used it recently enough to know whether this is likely to be a problem or not though.

In order to check for warnings too, you'll need the following change:

diff --git a/buildfile.m b/buildfile.m
index edab52b..dce3cba 100644
--- a/buildfile.m
+++ b/buildfile.m
@@ -3,7 +3,7 @@ import matlab.buildtool.tasks.CodeIssuesTask
 plan = buildplan(localfunctions);

 task = "check";
-plan(task) = CodeIssuesTask;
+plan(task) = CodeIssuesTask(WarningThreshold=0);
 plan.DefaultTasks = task;

 end
djmaxus commented 5 days ago

I think such a change can improve user experience if implemented along with configuring the Code Analyzer.

-plan(task) = CodeIssuesTask;
+plan(task) = CodeIssuesTask(WarningThreshold=0, Configuration='codeAnalyzerConfiguration.json');

The manually configured Code Analyzer could prevent unhelpful or unwanted warnings during CI checks and regular work on the project.