gecos-team/gecoscc-ui

View on GitHub
gecoscc/views/report_no_computer_users.py

Summary

Maintainability
C
1 day
Test Coverage

Function report_no_computer_users has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def report_no_computer_users(context, request, file_ext):
    '''
    Generate a report with all the no-computer users that belongs to a OU
    If the administrator is a superadmin the generated report will contain 
    all the users in the database. 
Severity: Minor
Found in gecoscc/views/report_no_computer_users.py - About 35 mins to fix

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

Similar blocks of code found in 18 locations. Consider refactoring.
Open

@view_config(route_name='report_file', renderer='csv',
             permission='edit',
             request_param=("type=no_computer_users", "format=csv"))
def report_no_computer_users_csv(context, request):
    filename = 'report_no_computer_users.csv'
Severity: Major
Found in gecoscc/views/report_no_computer_users.py and 17 other locations - About 2 hrs to fix
gecoscc/views/report_audit.py on lines 26..32
gecoscc/views/report_audit.py on lines 34..40
gecoscc/views/report_computer.py on lines 27..33
gecoscc/views/report_computer.py on lines 35..41
gecoscc/views/report_no_computer_users.py on lines 35..41
gecoscc/views/report_no_user_computers.py on lines 29..35
gecoscc/views/report_no_user_computers.py on lines 37..43
gecoscc/views/report_permission.py on lines 29..35
gecoscc/views/report_permission.py on lines 37..43
gecoscc/views/report_printers.py on lines 30..36
gecoscc/views/report_printers.py on lines 38..44
gecoscc/views/report_status.py on lines 30..36
gecoscc/views/report_status.py on lines 38..44
gecoscc/views/report_storages.py on lines 29..35
gecoscc/views/report_storages.py on lines 37..43
gecoscc/views/report_user.py on lines 28..34
gecoscc/views/report_user.py on lines 36..42

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 56.

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

Further Reading

Similar blocks of code found in 18 locations. Consider refactoring.
Open

@view_config(route_name='report_file', renderer='pdf',
             permission='edit',
             request_param=("type=no_computer_users", "format=pdf"))
def report_no_computer_users_pdf(context, request):
    filename = 'report_no_computer_users.pdf'
Severity: Major
Found in gecoscc/views/report_no_computer_users.py and 17 other locations - About 2 hrs to fix
gecoscc/views/report_audit.py on lines 26..32
gecoscc/views/report_audit.py on lines 34..40
gecoscc/views/report_computer.py on lines 27..33
gecoscc/views/report_computer.py on lines 35..41
gecoscc/views/report_no_computer_users.py on lines 27..33
gecoscc/views/report_no_user_computers.py on lines 29..35
gecoscc/views/report_no_user_computers.py on lines 37..43
gecoscc/views/report_permission.py on lines 29..35
gecoscc/views/report_permission.py on lines 37..43
gecoscc/views/report_printers.py on lines 30..36
gecoscc/views/report_printers.py on lines 38..44
gecoscc/views/report_status.py on lines 30..36
gecoscc/views/report_status.py on lines 38..44
gecoscc/views/report_storages.py on lines 29..35
gecoscc/views/report_storages.py on lines 37..43
gecoscc/views/report_user.py on lines 28..34
gecoscc/views/report_user.py on lines 36..42

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 56.

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

Further Reading

Similar blocks of code found in 9 locations. Consider refactoring.
Open

@view_config(route_name='report_file', renderer='templates/report.jinja2',
             permission='edit',
             request_param=("type=no_computer_users", "format=html"))
def report_no_computer_users_html(context, request):
    return report_no_computer_users(context, request, 'html')
Severity: Major
Found in gecoscc/views/report_no_computer_users.py and 8 other locations - About 50 mins to fix
gecoscc/views/report_audit.py on lines 42..46
gecoscc/views/report_computer.py on lines 43..47
gecoscc/views/report_no_user_computers.py on lines 45..49
gecoscc/views/report_permission.py on lines 45..49
gecoscc/views/report_printers.py on lines 46..50
gecoscc/views/report_status.py on lines 46..50
gecoscc/views/report_storages.py on lines 45..49
gecoscc/views/report_user.py on lines 44..48

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

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    header = (_(u'Username'),
              _(u'Name'),
              _(u'Email'),
              _(u'Phone'),
              _(u'Address'),
Severity: Major
Found in gecoscc/views/report_no_computer_users.py and 2 other locations - About 50 mins to fix
gecoscc/views/report_no_user_computers.py on lines 114..119
gecoscc/views/report_permission.py on lines 144..150

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

Further Reading

Identical blocks of code found in 4 locations. Consider refactoring.
Open

    return {'headers': header,
            'rows': rows,
            'default_order': [[ 0, 'asc' ]],
            'widths': widths,
            'report_title': title,
Severity: Major
Found in gecoscc/views/report_no_computer_users.py and 3 other locations - About 50 mins to fix
gecoscc/views/report_no_user_computers.py on lines 131..139
gecoscc/views/report_permission.py on lines 176..184
gecoscc/views/report_user.py on lines 127..135

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

Further Reading

There are no issues that match your filters.

Category
Status