demos/paired_ct_lung/demo_data.py
Function move_test_cases_into_correct_path
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
def move_test_cases_into_correct_path(test_cases, path_to_train, path_to_test):
folder_names = os.listdir(path_to_train)
os.chdir(path_to_train)
for case in test_cases:
for folder in folder_names:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
Open
if case in file:
os.chdir(os.path.join(path_to_train, folder))
source = file
destination = os.path.join(path_to_test, folder)
shutil.move(source, destination)
Avoid deeply nested control flow statements. Open
Open
if np.max(im_data) > 255.0:
im_data = ((im_data + 285) / (3770 + 285)) * 255.0 # rescale image
img = nib.Nifti1Image(im_data, affine=None)
nib.save(img, os.path.join(data_dir, folder, subfolder, file))
if np.max(img.dataobj) > 255.0:
Function move_files_into_correct_path
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def move_files_into_correct_path(