Showing 78 of 78 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
g1 = mgg(len(np.unique(labels_im.get_data()))-1, labels[idx])
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 36.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
temp_cc = OrderedDict((subj, nx.clustering(graphs[subj]).values())
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 36.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function reg_mri_pngs
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def reg_mri_pngs(mri, atlas, outdir, loc=0, mean=False, dim=4):
Avoid deeply nested control flow statements. Open
if verbose:
print "Saving slice:", slices
imsave(dirname + '/%04d.png' % slices,
Avoid deeply nested control flow statements. Open
if sesh is not None:
tpath = op.join(remo, 'sub-{}'.format(sub), 'ses-{}'.format(sesh))
tindir = op.join(inDir, 'sub-{}'.format(sub), 'ses-{}'.format(sesh))
else:
tpath = op.join(remo, 'sub-{}'.format(sub))
Function apply_warp
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def apply_warp(self, inp, out, ref, warp, xfm=None, mask=None):
Function visualize_fibs
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def visualize_fibs(fibs, fibfile, atlasfile, outdir, opacity, num_samples):
Function plot_density
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def plot_density(xs, ys, name=None, ylab=None, xlab=None):
Function tensor2fa
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def tensor2fa(tensors, tensor_name, dwi, derivdir, qcdir):
Function plot_degrees
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def plot_degrees(dats, name=None, ylab=None, xlab=None, hemi=True):
Function setup
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def setup(inDir, dwiListFile, bvalListFile, bvecListFile, mprageListFile):
Function s3_push_data
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def s3_push_data(bucket, remote, outDir, modifier, creds=True):
Function align_nonlinear
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def align_nonlinear(self, inp, ref, xfm, warp, mask=None):
Function plot_series
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def plot_series(dats, name=None, ylab=None, xlab=None, sort=False):
Function traces_to_panels
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def traces_to_panels(traces, names=[], ylabs=None, xlabs=None):
r, c, locs = panel_arrangement(len(traces))
multi = tools.make_subplots(rows=r, cols=c, subplot_titles=names)
for idx, loc in enumerate(locs):
if idx < len(traces):
- 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
Function get_braindata
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_braindata(brain_file):
"""
Opens a brain data series for a mask, mri image, or atlas.
Returns a numpy.ndarray representation of a brain.
- 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
Function align
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def align(self, inp, ref, xfm=None, out=None, dof=12, searchrad=True,
bins=256, interp=None, cost="mutualinfo"):
"""
Aligns two images and stores the transform between them
- 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
Function kill_jobs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def kill_jobs(jobdir, reason='"Killing job"'):
"""
Given a list of jobs, kills them all.
"""
cmd_template1 = 'aws batch cancel-job --job-id {} --reason {}'
- 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"