Showing 317 of 317 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
try:
import MySQLdb
CONNECTORS.append(('mysql', 'MySQL'))
assert MySQLdb
except (ImportError, AssertionError):
- 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 37.
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 3 locations. Consider refactoring. Open
@api.model
def create(self, vals):
new_record = super(ResUsers, self).create(vals)
new_record.set_groups_from_roles()
return new_record
- 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 37.
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 fields_view_get
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def fields_view_get(self, cr, user, view_id=None, view_type='form',
Function fields_view_get
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
Function _handle_callback_exception
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def _handle_callback_exception(self, cr, uid, model_name, method_name,
Function _import_data
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def _import_data(self, cr, uid, flds, data, model_obj, table_obj, log):
Function fields_view_get
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def fields_view_get(self, cr, user, view_id=None, view_type='form',
Function create_logs
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_logs(self, uid, res_model, res_ids, method,
Function fields_view_get
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
Function read_group
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def read_group(self, domain, fields, groupby, offset=0, limit=None,
Function execute
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def execute(self, cr, uid, ids, sqlquery, sqlparams=None, metadata=False,
Function fields_view_get
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def fields_view_get(
Similar blocks of code found in 2 locations. Consider refactoring. Open
if 'model_id' not in vals or not vals['model_id']:
raise UserError(_("No model defined to create line."))
- 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
if 'field_id' not in vals or not vals['field_id']:
raise UserError(_("No field defined to create line."))
- 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 _add_tz
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _add_tz(self, value, tz):
"""set the timezone on an rruleset and adjust dates there"""
value.tz = tz
tz = gettz(tz)
for rule in value._rrule:
- 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
with rec.sftp_connection() as remote:
# Directory must exist
try:
remote.makedirs(rec.folder)
except pysftp.ConnectionException:
Function _check_name
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _check_name(self):
for one in self:
if not one.label:
raise exceptions.ValidationError(
_("Field '%s' does not exist") % one.name)
- 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
for name in sorted(
n for n in remote.listdir(rec.folder)
if n.endswith(".dump.zip")
)[:-rec.days_to_keep]:
remote.unlink('%s/%s' % (rec.folder, name))
Avoid deeply nested control flow statements. Open
if basename.split('_')[0] not in keep_langs:
continue
yield filepath
Function onchange_server_type
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def onchange_server_type(