Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Code Compatibility Reporting #112

Merged
merged 3 commits into from
Apr 30, 2024

Conversation

simmsa
Copy link
Contributor

@simmsa simmsa commented Feb 1, 2024

Addressing issue #67.

Use MATLAB's built in analyzeCodeCompatibility function to run a code compatibility report. The output table provides insight into code that is not compatible with newer versions of MATLAB.

This runs the code compatibility report on the entire mhkit directory, and parses output from the code compatibility report. If "Error" is found is the Severity column, exit status 1 is returned.

The information in this output is relevant to core developers, but not for feature developers. Failing the code compatibility analysis should not make the test fail. We plan to add a separate GitHub action capture the output, but this action is mostly for visibility.

Remaining Tasks

  • Add separate GitHub Action to run this test

As of this PR there are only "Warnings" and "Info" in the code compatibility report. These should be addressed, but that work falls outside the scope of this PR.

Below is the condensed output from this report:

Identifier Severity Documentation Suppression File LineNumber ColumnRange
COLMP Warning Details none mhkit/tidal/graphics/plot_joint_probability_distribution.m 169 10 17
COLMP Warning Details none mhkit/tidal/graphics/plot_rose.m 104 17 24
COLMP Warning Details none mhkit/wave/graphics/plot_matrix.m 38 17 19
DATNM Info Details none mhkit/dolfyn/io/read_rdi.m 626 13 19
DATNM Info Details none mhkit/dolfyn/io/read_rdi.m 635 13 19
DATNM Info Details none mhkit/dolfyn/io/read_rdi.m 648 13 19
DATNM Info Details none mhkit/dolfyn/io/read_rdi.m 680 17 23
DATNM Info Details none mhkit/tests/QC_Test.m 45 24 30
DATNM Info Details none mhkit/tests/QC_Test.m 46 24 30
DATNM Info Details none mhkit/tests/QC_Test.m 71 24 30
DATNM Info Details none mhkit/tests/QC_Test.m 72 24 30
DATNM Info Details none mhkit/tests/QC_Test.m 162 28 34
DATNM Info Details none mhkit/tests/QC_Test.m 162 53 59
DATNM Info Details none mhkit/tests/River_TestIO.m 20 51 57
DATST Info Details none mhkit/dolfyn/io/read_rdi.m 626 21 27
DATST Info Details none mhkit/dolfyn/io/read_rdi.m 635 21 27
DATST Info Details none mhkit/dolfyn/io/read_rdi.m 648 21 27
DATST Info Details none mhkit/dolfyn/io/read_rdi.m 680 25 31
DATST Info Details none mhkit/tests/River_TestIO.m 19 30 36
DATST Info Details none mhkit/tests/River_TestIO.m 20 25 31
DATST Info Details none mhkit/tidal/io/request_noaa_data.m 80 18 24
DATST Info Details none mhkit/tidal/io/request_noaa_data.m 81 20 26
DATST Info Details none mhkit/wave/graphics/plot_compendium.m 36 5 11
DATST Info Details none mhkit/wave/graphics/plot_compendium.m 37 5 11
DISPLAYPROG Info Details none mhkit/tests/runCodeCompatibilityReport.m 11 5 11
GETFMT Info Details none mhkit/tests/Dolfyn_TestIO.m 290 28 35
GETFMT Info Details none mhkit/tests/Dolfyn_Test_Rotate.m 395 28 35
HISTC Info Details none mhkit/dolfyn/io/read_signature.m 1514 22 26
IDISVARLOW Warning Details none mhkit/river/resource/Froude_number.m 28 8 14
LEGPVPAIR Warning Details none mhkit/wave/graphics/plot_chakrabarti.m 71 40 51
VERLESSMATLAB Info Details none mhkit/dolfyn/rotate/tensorproduct_core.m 6 5 15

Details:

COLMP Details (Warning):

  • In R2019a and previous releases, the default colormap size is 64.
  • Starting in R2019b, colormaps have 256 colors by default.
  • If your code depends on a colormap having 64 colors, specify the number of colors when querying the colormap.
  • For example, parula(64) queries the 64-color parula colormap.

DATNM Details (Info):

  • 'datenum' is not recommended.
  • With appropriate code changes, use 'datetime' instead.

DATST Details (Info):

  • 'datestr' is not recommended.
  • With appropriate code changes, use 'datetime' instead.

DISPLAYPROG Details (Info):

  • Programmatic use of DISPLAY is not recommended.
  • Use DISP or FPRINTF instead.

GETFMT Details (Info):

  • Using get for retrieving values of numeric display format is not recommended.
  • With appropriate code changes, use 'settings' object instead.

HISTC Details (Info):

  • 'histc' is not recommended.
  • With appropriate code changes, use 'histcounts' instead.

IDISVARLOW Details (Warning):

  • To avoid a potential conflict with functions on the path, explicitly define the variable before indexing into it.

LEGPVPAIR Details (Warning):

  • 'legend' has changed and might interpret the name of an argument as a legend property instead of a label.
  • To include a label with the same name as a legend property, specify the labels using a cell array or string array.
  • Refer to the documentation for a list of affected property names.

VERLESSMATLAB Details (Info):

  • verLessThan('matlab', ...) is not recommended.
  • With appropriate code changes, use 'isMATLABReleaseOlderThan' instead.

@simmsa simmsa added the enhancement New feature or request label Feb 1, 2024
@simmsa simmsa marked this pull request as draft February 1, 2024 17:31
Documentation: https://www.mathworks.com/help/matlab/ref/codecompatibilityreport.html

Output is displayed and parsed. If "Error" is found is the Severity
column, exit status 1 is returned.

Planning to add a separate GitHub action that runs this report only.
@simmsa simmsa force-pushed the add-code-compatibility-report branch from 2c103f3 to 8d14ad4 Compare February 1, 2024 20:46
@simmsa simmsa marked this pull request as ready for review February 2, 2024 15:27
@simmsa simmsa requested a review from rpauly18 February 2, 2024 15:27
@simmsa
Copy link
Contributor Author

simmsa commented Mar 22, 2024

@rpauly18, could you take a look at this PR when you have time? It introduces a code compatibility test and action that fails if there are any ERROR level code compatibility issues across the entire codebase. This addition is beneficial because it flags older function usage for contributed code and allows us to address legacy code sections before they cause issues for the end user.

@simmsa simmsa changed the title Code Compatibility Reporting Add Code Compatibility Reporting Apr 30, 2024
@rpauly18 rpauly18 merged commit 8f29f90 into MHKiT-Software:master Apr 30, 2024
88 checks passed
simmsa added a commit to simmsa/MHKiT-MATLAB that referenced this pull request May 13, 2024
* Feature: Add runner for code compatibility report

Documentation: https://www.mathworks.com/help/matlab/ref/codecompatibilityreport.html

Output is displayed and parsed. If "Error" is found is the Severity
column, exit status 1 is returned.

Planning to add a separate GitHub action that runs this report only.

* Actions: Initial test of code compatibility report

* Actions: Remove unnecessary steps from code compatibility

---------

Co-authored-by: Andrew Simms <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants