Skip to content

Commit

Permalink
Format check (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanzulli committed Dec 15, 2024
1 parent cf9dc9d commit 9597737
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 126 deletions.
12 changes: 1 addition & 11 deletions miss_hit.cfg
Original file line number Diff line number Diff line change
@@ -1,44 +1,34 @@
# Style guide configuration for MISS_HIT
# Reference: https://florianschanda.github.io/miss_hit/style_checker.html

# Format check parameters:
# Maximum allowed length for a single line of code (in characters)
# Helps maintain code readability without unnecessary horizontal scrolling.
line_length: 200

# Number of spaces a single tab corresponds to
# Ensures consistent indentation throughout the codebase.
tab_width: 2

# Regular expression for function names
# Enforces CamelCase naming convention: each word starts with an uppercase letter, no underscores.
regex_function_name: "[A-Z][a-zA-Z0-9]*"

# Regular expression for script file names
# Enforces CamelCase naming convention for file names: no spaces, starts with an uppercase letter.
regex_script_name: "[A-Z][a-zA-Z0-9]*"

# Regular expression for parameter (variable) names
# Enforces snake_case naming for function parameters (unchanged for clarity and consistency).
regex_parameter_name: "[a-zA-Z]+(_[a-zA-Z]+)*"

# Copyright owner entity
# Adds a copyright notice with the specified entity name.
copyright_entity: "ONSAS"

# Metrics for code quality

# "cnest" (Control Nesting Depth): Maximum allowed nesting level of control structures (e.g., loops, conditionals)
# Helps reduce code complexity and improve maintainability.
metric "cnest": limit 6

# "file_length": Maximum allowed number of lines in a single file
# Keeps files manageable and easier to navigate.
metric "file_length": limit 1000

# "cyc" (Cyclomatic Complexity): Maximum allowed complexity of a single function
# A lower value ensures that functions remain simple and focused.
metric "cyc": limit 35

# "parameters": Maximum allowed number of parameters for a single function
# Encourages simpler function signatures and improves readability.
metric "parameters": limit 7
60 changes: 31 additions & 29 deletions test/gaussIntegrationTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,55 @@

function resultBoolean = gaussIntegrationTest()

addpath( genpath( [ pwd filesep '..' filesep 'src'] ));
addpath(genpath([pwd filesep '..' filesep 'src']));

plots_boolean = true ;
plots_boolean = true;

point_nums_to_test = [ 1:10 12 14 16 28 ] ;
% point_nums_to_test = [ 1:10 ]
int_values = zeros( size(point_nums_to_test) ) ;
point_nums_to_test = [1:10 12 14 16 28];
% point_nums_to_test = [ 1:10 ]
int_values = zeros(size(point_nums_to_test));

a = -1.5 ; b = 1 ;
%analyInt = -50*.5 + -50*1*.5 + 100*.5*.5 + 100*.5 ;
analyInt = 20 * ( b^5/5 - a^5/5 ) ;
a = -1.5;
b = 1;
% analyInt = -50*.5 + -50*1*.5 + 100*.5*.5 + 100*.5 ;
analyInt = 20 * (b^5 / 5 - a^5 / 5);

xs = -1.5:.02:1;
ys = 0;
for i=1:length(xs)
for i = 1:length(xs)
ys(i) = test_fun_to_integrate(xs(i));
end

if plots_boolean
figure
plot( xs, ys, 'g-x' )
title('test_fun_to_integrate')
figure;
plot(xs, ys, 'g-x');
title('test_fun_to_integrate');
end

for j=1:length( point_nums_to_test)
[xIntPoints, wIntPoints] = gaussPointsAndWeights ( point_nums_to_test(j) ) ;
for j = 1:length(point_nums_to_test)
[xIntPoints, wIntPoints] = gaussPointsAndWeights (point_nums_to_test(j));

for k=1:length(xIntPoints)
for k = 1:length(xIntPoints)
int_values(j) = int_values(j) + ...
wIntPoints(k) * test_fun_to_integrate( (b-a)/2 * xIntPoints(k) + (a+b)/2 ) * ( (b-a) /2 ) ;
wIntPoints(k) * test_fun_to_integrate((b - a) / 2 * xIntPoints(k) + (a + b) / 2) * ((b - a) / 2);
end
end

if plots_boolean
% numericalInt = quadl( 'test_fun_to_integrate', a, b )
figure
plot(point_nums_to_test, int_values,'b-x')
hold on, grid on
plot(point_nums_to_test, analyInt*ones(size(point_nums_to_test)),'r-o')
% numericalInt = quadl( 'test_fun_to_integrate', a, b )
figure;
plot(point_nums_to_test, int_values, 'b-x');
hold on;
grid on;
plot(point_nums_to_test, analyInt * ones(size(point_nums_to_test)), 'r-o');
end

int_values(3:end)
analyInt*ones(1,length(point_nums_to_test)-2)
int_values(3:end);
analyInt * ones(1, length(point_nums_to_test) - 2);

resultBoolean = max( abs( int_values(3:end) - analyInt*ones(1,length(point_nums_to_test)-2) ) ) / abs( analyInt ) < 1e-8 ;
resultBoolean = max(abs(int_values(3:end) - analyInt * ones(1, length(point_nums_to_test) - 2))) / abs(analyInt) < 1e-8;

% ========================================================================================
% ========================================================================================
function ys = test_fun_to_integrate( xinput )
ys = 20 * xinput .^ 4 ;
% ========================================================================================
% ========================================================================================
function ys = test_fun_to_integrate(xinput)
ys = 20 * xinput.^4;
82 changes: 44 additions & 38 deletions test/runTestProblems_local.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,53 @@
% This functions reads a text file with the norms of the forces at
% each iteration of the code execution and generates a series of plots

close all, clear all;
addpath( genpath( [ pwd filesep '..' filesep 'src' filesep ]) ); octaveBoolean = isThisOctave ;
close all;
clear all;
addpath(genpath([pwd filesep '..' filesep 'src' filesep]));
octaveBoolean = isThisOctave;

Check warning on line 24 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L21-L24

Added lines #L21 - L24 were not covered by tests

setenv('TESTS_RUN','yes')
setenv('TESTS_RUN', 'yes');

Check warning on line 26 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L26

Added line #L26 was not covered by tests

keyfiles = { ...
'addedMassPendulum/addedMassPendulum.m' ...
; 'beamLinearVibration/beamLinearVibration.m' ...
; 'beamTrussJoint/beamTrussJoint.m' ...
; 'cantileverModalAnalysis/cantileverModalAnalysis.m' ...
; 'cantileverPlate/cantileverPlate.m' ...
; 'cantileverSelfWeight/cantileverSelfWeight.m' ...
; 'dragBeamReconfiguration/dragBeamReconfiguration.m' ...
; 'eulerColumn/eulerColumn.m' ...
; 'frameLinearAnalysis/frameLinearAnalysis.m' ...
; 'linearAerodynamics/linearAerodynamics.m' ...
; 'nonLinearPendulum/nonLinearPendulum.m' ...
; 'platePatchTest/platePatchTest.m' ...
; 'ringPlaneStrain/ringPlaneStrain.m' ...
; 'simplePropeller/simplePropeller.m' ...
; 'springMass/springMass.m' ...
; 'staticVonMisesTruss/staticVonMisesTruss.m' ...
; 'staticPlasticVonMisesTruss/staticPlasticVonMisesTruss.m' ...
; 'uniaxialCompression/uniaxialCompression.m' ...
; 'uniaxialExtension/uniaxialExtension.m' ...
; 'uniformCurvatureCantilever/uniformCurvatureCantilever.m' ...
; 'VIVCantilever/VIVCantilever.m' ...
}
'addedMassPendulum/addedMassPendulum.m' ...
; 'beamLinearVibration/beamLinearVibration.m' ...
; 'beamTrussJoint/beamTrussJoint.m' ...
; 'cantileverModalAnalysis/cantileverModalAnalysis.m' ...
; 'cantileverPlate/cantileverPlate.m' ...
; 'cantileverSelfWeight/cantileverSelfWeight.m' ...
; 'dragBeamReconfiguration/dragBeamReconfiguration.m' ...
; 'eulerColumn/eulerColumn.m' ...
; 'frameLinearAnalysis/frameLinearAnalysis.m' ...
; 'linearAerodynamics/linearAerodynamics.m' ...
; 'nonLinearPendulum/nonLinearPendulum.m' ...
; 'platePatchTest/platePatchTest.m' ...
; 'ringPlaneStrain/ringPlaneStrain.m' ...
; 'simplePropeller/simplePropeller.m' ...
; 'springMass/springMass.m' ...
; 'staticVonMisesTruss/staticVonMisesTruss.m' ...
; 'staticPlasticVonMisesTruss/staticPlasticVonMisesTruss.m' ...
; 'uniaxialCompression/uniaxialCompression.m' ...
; 'uniaxialExtension/uniaxialExtension.m' ...
; 'uniformCurvatureCantilever/uniformCurvatureCantilever.m' ...
; 'VIVCantilever/VIVCantilever.m' ...
};

current = 1 ; verifBoolean = 1 ; testDir = pwd ;
current = 1;
verifBoolean = 1;
testDir = pwd;

Check warning on line 54 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L52-L54

Added lines #L52 - L54 were not covered by tests

num_tests = length(keyfiles) ;
num_tests = length(keyfiles);

Check warning on line 56 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L56

Added line #L56 was not covered by tests
while (current <= num_tests) && (verifBoolean == 1)

% run current example
fprintf([' === running script: ' keyfiles{current} '\n' ]);
fprintf([' === running script: ' keyfiles{current} '\n']);

Check warning on line 60 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L60

Added line #L60 was not covered by tests

aux_time = cputime();

% save key files data to avoid clear all commands
save( '-mat', 'exData.mat', 'current', 'keyfiles', 'testDir', 'aux_time' );
save('-mat', 'exData.mat', 'current', 'keyfiles', 'testDir', 'aux_time');

Check warning on line 65 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L65

Added line #L65 was not covered by tests

run( [ pwd filesep '..' filesep 'examples' filesep keyfiles{current} ] ) ;
run([pwd filesep '..' filesep 'examples' filesep keyfiles{current}]);

Check warning on line 67 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L67

Added line #L67 was not covered by tests

if verifBoolean
status = 'PASSED';
Expand All @@ -69,19 +73,21 @@
end

% reload key files data and increment current
load('exData.mat') ; num_tests = length(keyfiles) ;
load('exData.mat');
num_tests = length(keyfiles);

Check warning on line 77 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L76-L77

Added lines #L76 - L77 were not covered by tests

aux_time = cputime() - aux_time ; keyfiles{current,2} = aux_time ;
aux_time = cputime() - aux_time;
keyfiles{current, 2} = aux_time;

Check warning on line 80 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L79-L80

Added lines #L79 - L80 were not covered by tests

fprintf([' === test problem %2i: %s in %8.1e s === \n\n'], current, status, aux_time );
fprintf([' === test problem %2i: %s in %8.1e s === \n\n'], current, status, aux_time);

Check warning on line 82 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L82

Added line #L82 was not covered by tests

current = current + 1 ;
current = current + 1;

Check warning on line 84 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L84

Added line #L84 was not covered by tests
delete('exData.mat');
cd ( testDir )
cd (testDir);

Check warning on line 86 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L86

Added line #L86 was not covered by tests
end

if verifBoolean ==1
fprintf('all test examples PASSED!\n')
if verifBoolean == 1
fprintf('all test examples PASSED!\n');

Check warning on line 90 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L89-L90

Added lines #L89 - L90 were not covered by tests
else
error('test examples not passed.')
error('test examples not passed.');

Check warning on line 92 in test/runTestProblems_local.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_local.m#L92

Added line #L92 was not covered by tests
end
96 changes: 48 additions & 48 deletions test/runTestProblems_moxunit_disp.m
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
% function for testing ONSAS using moxunit
% ----------------------------------------
function test_suite=runTestProblems_moxunit_disp
function test_suite = runTestProblems_moxunit_disp
% initialize tests
try
test_functions=localfunctions()
test_functions = localfunctions();

Check warning on line 6 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L6

Added line #L6 was not covered by tests
catch
end

% set auxiliar environment variable
setenv('TESTS_RUN', 'yes')
setenv('TESTS_RUN', 'yes');

Check warning on line 11 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L11

Added line #L11 was not covered by tests

% initialize the MOxUnit test suite
initTestSuite;

function test_1
beamLinearVibration
assertEqual( verifBoolean, true );
beamLinearVibration;
assertEqual(verifBoolean, true);

Check warning on line 18 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L17-L18

Added lines #L17 - L18 were not covered by tests

function test_2
cantileverModalAnalysis
assertEqual( verifBoolean, true );
cantileverModalAnalysis;
assertEqual(verifBoolean, true);

Check warning on line 22 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L21-L22

Added lines #L21 - L22 were not covered by tests

function test_3
cantileverSelfWeight
assertEqual( verifBoolean, true );
cantileverSelfWeight;
assertEqual(verifBoolean, true);

Check warning on line 26 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L25-L26

Added lines #L25 - L26 were not covered by tests

function test_4
dragBeamReconfiguration
assertEqual( verifBoolean, true );
dragBeamReconfiguration;
assertEqual(verifBoolean, true);

Check warning on line 30 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L29-L30

Added lines #L29 - L30 were not covered by tests

function test_5
eulerColumn
assertEqual( verifBoolean, true );
eulerColumn;
assertEqual(verifBoolean, true);

Check warning on line 34 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L33-L34

Added lines #L33 - L34 were not covered by tests

function test_6
frameLinearAnalysis
assertEqual( verifBoolean, true );
frameLinearAnalysis;
assertEqual(verifBoolean, true);

Check warning on line 38 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L37-L38

Added lines #L37 - L38 were not covered by tests

function test_7
linearAerodynamics
assertEqual( verifBoolean, true );
linearAerodynamics;
assertEqual(verifBoolean, true);

Check warning on line 42 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L41-L42

Added lines #L41 - L42 were not covered by tests

function test_8
ringPlaneStrain
assertEqual( verifBoolean, true );
ringPlaneStrain;
assertEqual(verifBoolean, true);

Check warning on line 46 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L45-L46

Added lines #L45 - L46 were not covered by tests

function test_9
nonLinearPendulum
assertEqual( verifBoolean, true );
nonLinearPendulum;
assertEqual(verifBoolean, true);

Check warning on line 50 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L49-L50

Added lines #L49 - L50 were not covered by tests

function test_10
springMass
assertEqual( verifBoolean, true );
springMass;
assertEqual(verifBoolean, true);

Check warning on line 54 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L53-L54

Added lines #L53 - L54 were not covered by tests

function test_11
simplePropeller
assertEqual( verifBoolean, true );
simplePropeller;
assertEqual(verifBoolean, true);

Check warning on line 58 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L57-L58

Added lines #L57 - L58 were not covered by tests

function test_12
staticVonMisesTruss
assertEqual( verifBoolean, true );
staticVonMisesTruss;
assertEqual(verifBoolean, true);

Check warning on line 62 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L61-L62

Added lines #L61 - L62 were not covered by tests

function test_13
uniaxialCompression
assertEqual( verifBoolean, true );
uniaxialCompression;
assertEqual(verifBoolean, true);

Check warning on line 66 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L65-L66

Added lines #L65 - L66 were not covered by tests

function test_14
uniaxialExtension
assertEqual( verifBoolean, true);
uniaxialExtension;
assertEqual(verifBoolean, true);

Check warning on line 70 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L69-L70

Added lines #L69 - L70 were not covered by tests

function test_15
uniformCurvatureCantilever
assertEqual( verifBoolean, true);
function test_15
uniformCurvatureCantilever;
assertEqual(verifBoolean, true);

Check warning on line 74 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L73-L74

Added lines #L73 - L74 were not covered by tests

function test_16
VIVCantilever
assertEqual( verifBoolean, true );
VIVCantilever;
assertEqual(verifBoolean, true);

Check warning on line 78 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L77-L78

Added lines #L77 - L78 were not covered by tests

function test_17
beamTrussJoint
assertEqual( verifBoolean, true );
beamTrussJoint;
assertEqual(verifBoolean, true);

Check warning on line 82 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L81-L82

Added lines #L81 - L82 were not covered by tests

function test_18
staticPlasticVonMisesTruss
assertEqual( verifBoolean, true );
staticPlasticVonMisesTruss;
assertEqual(verifBoolean, true);

Check warning on line 86 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L85-L86

Added lines #L85 - L86 were not covered by tests

function test_19
platePatchTest
assertEqual( verifBoolean, true );
platePatchTest;
assertEqual(verifBoolean, true);

Check warning on line 90 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L89-L90

Added lines #L89 - L90 were not covered by tests

function test_20
cantileverPlate
assertEqual( verifBoolean, true );
cantileverPlate;
assertEqual(verifBoolean, true);

Check warning on line 94 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L93-L94

Added lines #L93 - L94 were not covered by tests

function test_21
addedMassPendulum
assertEqual( verifBoolean, true );
addedMassPendulum;
assertEqual(verifBoolean, true);

Check warning on line 98 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L97-L98

Added lines #L97 - L98 were not covered by tests

function test_22
assertEqual( gaussIntegrationTest, true);
assertEqual(gaussIntegrationTest, true);

Check warning on line 101 in test/runTestProblems_moxunit_disp.m

View check run for this annotation

Codecov / codecov/patch

test/runTestProblems_moxunit_disp.m#L101

Added line #L101 was not covered by tests

0 comments on commit 9597737

Please sign in to comment.