Code Monkey home page Code Monkey logo

Comments (7)

mshavliuk avatar mshavliuk commented on September 27, 2024 1

I would propose not to just fix certain files of the project manually and hope that the repository will stay clean and well organized on its own, but introduce a dedicated GitHub CI action with some Matlab linter. It would block all pull requests that do not satisfy the agreed code style.

There are several linters and static code analysis tools available for MATLAB that you can use for GitHub CI (Continuous Integration) to ensure code quality and enforce best practices. Here are a few popular options:

These tools can be integrated into your GitHub CI workflow by adding the necessary commands and configurations to your CI pipeline configuration file (e.g., .github/workflows/main.yml).

from zeffiro_interface.

SeSodesa avatar SeSodesa commented on September 27, 2024 1
* MATLAB Code Analyzer (M-Lint): MATLAB itself provides a built-in code analysis tool called M-Lint. It helps identify potential issues and provides suggestions to improve code quality. You can run M-Lint from the MATLAB command window or integrate it into your CI workflow using the MATLAB command-line interface.
  Link: https://blogs.mathworks.com/community/2008/09/08/let-m-lint-help-simplify-your-code/

There is actually a newer linter provided by MathWorks, that has superseded mlint, called checkcode. I've been using it to check files when not using the Matlab editor, while writing code. We should probably use that in CI instead, if we choose to stick to built-in functionality.

from zeffiro_interface.

SeSodesa avatar SeSodesa commented on September 27, 2024 1

The pull request #218 will introduce a linting action, which will be run when things are pushed to the main_development_branch (although for testing purposes it is currently set to run when commits are pushed to the related feature branch). I might also add an action that will be run when a pull request is made towards master.

What is still missing is a comprehensive set of linter messages we wish to disallow. The list of possible values can be found at https://se.mathworks.com/help/matlab/matlab_env/index-of-code-analyzer-checks.html.

from zeffiro_interface.

SeSodesa avatar SeSodesa commented on September 27, 2024

There is one concern, though: we would need to be sponsored by MathWorks to use the Matlab Actions they provide:

Sponsored License -- for use in support of a program or activity sponsored by MathWorks. Not for government, commercial or other non-sponsored organizational use.

@sampsapursiainen Are we considered to be sponsored by MathWorks?

from zeffiro_interface.

SeSodesa avatar SeSodesa commented on September 27, 2024

Starting from R2022b, Matlab also provides the codeIssues function, which provides more thorough information than mlint and checkcode. Most importantly, it provides information related to issue severity, in the form of matlab.codeanalysis.IssueSeverity.{info, warning, error} enumeration, per each issue discovered. The linter now uses that by default, but can also call mlint and checkcode if needed.

from zeffiro_interface.

SeSodesa avatar SeSodesa commented on September 27, 2024

I wrote a little web scraper (link), that allowed me to generate a CSV of Matlab's linter messages and their severities. The file could be loaded as a Matlab table, which could be used with mlint and checkcode to block messages with a severity of error, as long as the CSV was loaded into the repo, preferrably into the +utilities/ folder.

from zeffiro_interface.

SeSodesa avatar SeSodesa commented on September 27, 2024

Looks like the related pull request was merged. The linter message file mentioned above was not yet added, but since most of the linter messages seem to be related to the use of eval, which was already in the list of unwanted warnings, I think we can close this.

from zeffiro_interface.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.