ALCD icon indicating copy to clipboard operation
ALCD copied to clipboard

Code quality analysis

Open cadauxe opened this issue 3 months ago • 0 comments

We assessed the code quality based on the specified requirements, and all criteria have been met.

Below are more details about each requirements and the methods we used to evaluate them.

- Comments has to represent at least 20 % of the code

- Each method and function has to be inferior to 100 lines

Running the following command line to test the number of lines of functions and methods, we obtain the results :

$ pylint --recursive=y --disable=all --fail-under=10 --enable=too-many-statements .

-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

This command line tests if the number of statements in each method and function is inferior to 50. The rate 10,00/10 indicates that there is no function or method in the code that has more than 50 statements. Therefore, the requirement has been met.

- The number of nested loops has to be inferior than 7

Running the following command line to test the number of nested loops, we obtain the results :

$ pylint --recursive=y --disable=all --fail-under=10 --enable=too-many-nested-blocks .

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

This command line tests if the number imbrications is inferior to 5. The rate 10,00/10 indicates that there is no function or method in the code that has more than 5 nested loops. Therefore, the requirement has been met.

- Cyclomatic complexity McCabe V(g) has to be inferior to 25

Running the following command line to test the cyclomatic complexity, we obtain the results :

$ radon cc -s .

Complete output of the test command line
find_directory_names.py
    F 97:0 get_L1C_dir - A (4)
    F 32:0 get_all_dates - A (3)
    F 69:0 get_closest_dates - A (3)
    F 58:0 is_valid_date - A (2)
layers_creation.py
    F 39:0 empty_shapefile_creation - A (5)
    F 75:0 create_all_classes_empty_layers - A (5)
    F 103:0 populate_layer - A (3)
    F 145:0 create_no_data_shp - A (1)
    F 172:0 simplify_geometry - A (1)
    F 182:0 main - A (1)
metrics_exploitation.py
    F 42:0 matrix_loading - C (11)
    F 141:0 multi_to_binary_confusion_matrix - C (11)
    F 314:0 retrieve_Kfold_data - C (11)
    F 258:0 save_model_metrics - B (9)
    F 180:0 binary_stats - A (5)
    F 218:0 get_model_metrics - A (3)
    F 379:0 plot_metrics - A (3)
    F 100:0 multiclass_stats - A (2)
    F 421:0 get_all_locations_dates - A (2)
    F 123:0 get_binary_classes - A (1)
    F 410:0 load_previous_global_parameters - A (1)
split_samples.py
    F 168:0 k_split - C (17)
    F 49:0 split_points_sample - C (16)
    F 280:0 add_all_fields - A (5)
    F 151:0 global_proportion_type - A (4)
    F 28:0 shuffle_two_lists - A (2)
    F 273:0 get_field_names - A (2)
    F 11:0 get_random_splitting_lists - A (1)
contour_from_labeled.py
    F 89:0 create_labelisation_contours - B (7)
    F 168:0 rgb_contours_stacking - A (4)
    F 36:0 single_contour_from_labeled_dilatation - A (3)
    F 232:0 quick_contours - A (1)
masks_preprocessing.py
    F 38:0 split_and_augment - A (4)
    F 139:0 masks_preprocess - A (4)
    F 80:0 load_kfold - A (3)
    F 106:0 rasterize_shp - A (1)
OTB_workflow.py
    F 244:0 otb_train - B (6)
    F 166:0 select_samples - A (5)
    F 55:0 create_directories - A (4)
    F 148:0 get_samples_nb - A (4)
    F 314:0 train_model - A (4)
    F 413:0 image_classification - A (4)
    F 485:0 compute_mat_conf - A (4)
    F 130:0 get_bands_qty - A (3)
    F 290:0 scikit_train - A (2)
    F 345:0 otb_class - A (2)
    F 366:0 scikit_class - A (2)
    F 80:0 compute_image_stats - A (1)
    F 100:0 compute_samples_stats - A (1)
    F 216:0 extract_samples - A (1)
    F 445:0 confidence_map_viz - A (1)
    F 463:0 fancy_classif_viz - A (1)
    F 529:0 classification_regularization - A (1)
    F 555:0 create_contour_from_labeled - A (1)
    F 577:0 main - A (1)
merge_shapefiles.py
    F 32:0 merge_shapefiles - A (5)
expand_point_region.py
    F 35:0 create_squares - B (6)
all_run_alcd.py
    F 100:0 run_all - C (17)
    F 244:0 all_run_alcd - C (11)
    F 62:0 invitation_to_copy - A (5)
    F 200:0 str2bool - A (4)
    F 47:0 initialization_global_parameters - A (1)
    F 182:0 first_it_worklfow - A (1)
    F 214:0 getarguments - A (1)
    F 327:0 main - A (1)
<unknown>:238: SyntaxWarning: invalid escape sequence '\ '
L1C_band_composition.py
    F 401:0 create_image_compositions - C (11)
    F 45:0 create_composit_band - B (7)
    F 324:0 user_process - B (6)
    F 96:0 create_specific_indices - A (5)
    F 151:0 create_ratio_bands - A (4)
    F 600:0 str2bool - A (4)
    F 236:0 compose_bands_heavy - A (3)
    F 265:0 dtm_addition - A (3)
    F 303:0 load_module - A (3)
    F 524:0 time_diff_feat - A (3)
    F 533:0 use_dtm - A (3)
    F 293:0 resize_band - A (2)
    F 505:0 put_band_heavy_tif - A (2)
    F 517:0 create_new_indices - A (2)
    F 125:0 create_time_difference_band - A (1)
    F 175:0 create_contours_density - A (1)
    F 210:0 create_variation_coeff - A (1)
    F 547:0 create_texture_feat - A (1)
    F 560:0 create_no_data_tif - A (1)
    F 614:0 main - A (1)
synthese_alcd_runs.py
    F 61:0 compute_samples_evolution_statistics - C (12)
    F 43:0 get_main_directories - A (5)
    F 123:0 plot_samples_evolution_statistics - A (3)
    F 177:0 count_points_in_dir - A (3)
    F 163:0 count_points_in_shp - A (1)
    F 193:0 mean_confidence - A (1)
    F 203:0 main - A (1)
confidence_map_exploitation.py
    F 111:0 confidence_map_mean - C (12)
    F 271:0 plot_samples_evolution - B (6)
    F 203:0 compute_all_confidence_stats - A (4)
    F 60:0 shapefile_rasterization - A (3)
    F 231:0 plot_confidence_evolution - A (3)
    F 41:0 confidence_map_change - A (2)
    F 321:0 main - A (1)
quicklook_generator.py
    F 56:0 create_all_quicklook - A (4)
    F 98:0 quicklook_generator - A (3)
    F 35:0 create_jpg - A (2)
    F 87:0 getarguments - A (1)
    F 114:0 main - A (1)
docs/source/notebooks/utils.py
    F 15:0 show_raster - A (1)
    F 66:0 show_tree - A (1)
tests/conftest.py
    C 30:0 ALCDTestsData - A (2)
    F 39:0 alcd_paths - A (1)
    M 32:4 ALCDTestsData.__post_init__ - A (1)
tests/test_run_alcd.py
    F 86:0 check_expected_features_content_alcd - A (5)
    F 40:0 check_expected_quicklook_results - A (3)
    F 53:0 check_expected_alcd_results - A (3)
    F 73:0 check_expected_features_alcd - A (3)
    F 212:0 test_scikit_alcd - A (3)
    F 252:0 test_user_prim_alcd - A (3)
    F 130:0 prepare_test_dir - A (2)
    F 175:0 test_run_alcd - A (2)
    F 310:0 test_run_alcd_gen_features - A (2)
    F 346:0 test_quicklook - A (2)
tests/data/users_function.py
    F 3:0 my_process - A (1)
color_tables/generate_color_tables.py
    F 26:0 generate_qgis_table - A (2)
    F 38:0 generate_otb_table - A (2)
    C 16:0 Legend_entry - A (2)
    F 49:0 define_dico - A (1)
    F 83:0 main - A (1)
    M 19:1 Legend_entry.__init__ - A (1)
alcd_params/params_reader.py
    F 13:0 read_global_parameters - A (1)
    F 32:0 read_models_parameters - A (1)
    F 51:0 read_paths_parameters - A (1)
alcd_params/global_parameters.py
    C 169:0 UserChoices - A (5)
    M 202:4 UserChoices.parse_yyyymmdd - A (4)
    C 7:0 Classification - A (1)
    C 19:0 Features - A (1)
    C 46:0 General - A (1)
    C 94:0 LocalPaths - A (1)
    C 109:0 Mask - A (1)
    C 124:0 PostProcessing - A (1)
    C 142:0 TrainingParameters - A (1)
    C 232:0 ALCDConfig - A (1)
alcd_params/models_parameters.py
    C 5:0 LibSVMConfig - A (1)
    C 29:0 BoostConfig - A (1)
    C 50:0 DTConfig - A (1)
    C 80:0 GBTConfig - A (1)
    C 101:0 ANNConfig - A (1)
    C 146:0 RFConfig - A (1)
    C 176:0 KNNConfig - A (1)
    C 187:0 SVMConfig - A (1)
    C 204:0 RFSKConfig - A (1)
    C 224:0 ADAConfig - A (1)
    C 241:0 XTREEConfig - A (1)
    C 258:0 GRADConfig - A (1)
    C 272:0 HISTConfig - A (1)
    C 286:0 MLConfig - A (1)
alcd_params/paths_parameters.py
    C 5:0 GlobalChainsPaths - A (1)
    C 35:0 DataPaths - A (1)
    C 50:0 TileLocation - A (1)
    C 62:0 ProjectConfig - A (1)

The maximum cyclomatic complexity McCabe V(g) obtained is 17, which is smaller than 25.

- Tests must cover at least 65% of the code

The coverage reports for all tools can be downloaded in the Artifacts section of this page. Running the following command line to compute the coverage of the tests, we obtain the results :

$ pytest --cov=tests --cov-report html --capture=no -v

------------------------------------------------------------------------------
TOTAL                                             2366    153    97%

The tests cover 97% of the code, which is greater than the minimum requirement of 65%.

cadauxe avatar Sep 01 '25 09:09 cadauxe