gecos-team/gecoscc-ui

View on GitHub
gecoscc/views/report_status.py

Summary

Maintainability
D
1 day
Test Coverage

Function report_status has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

def report_status(context, request, file_ext):
    '''
    Generate a report with all the users that belongs to an 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_status.py - About 4 hrs 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='pdf',
             permission='edit',
             request_param=("type=status", "format=pdf"))
def report_status_pdf(context, request):
    filename = 'report_status.pdf'
Severity: Major
Found in gecoscc/views/report_status.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_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_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='csv',
             permission='edit',
             request_param=("type=status", "format=csv"))
def report_status_csv(context, request):
    filename = 'report_status.csv'
Severity: Major
Found in gecoscc/views/report_status.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_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 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 2 locations. Consider refactoring.
Open

            if last_agent_run_time != 0:
                row.append(datetime.utcfromtimestamp(
                    last_agent_run_time).strftime('%d/%m/%Y %H:%M:%S'))
            else:
                row.append('--')
Severity: Major
Found in gecoscc/views/report_status.py and 1 other location - About 1 hr to fix
gecoscc/views/report_status.py on lines 152..156

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

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 2 locations. Consider refactoring.
Open

            if last_agent_run_time != 0:
                row.append(datetime.utcfromtimestamp(
                    last_agent_run_time).strftime('%d/%m/%Y %H:%M:%S'))
            else:
                row.append(' -- ')
Severity: Major
Found in gecoscc/views/report_status.py and 1 other location - About 1 hr to fix
gecoscc/views/report_status.py on lines 169..173

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

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

            if file_ext == 'csv':
                row.append(treatment_string_to_csv(item, 'name'))
            else:
                row.append(get_html_node_link(item))
Severity: Major
Found in gecoscc/views/report_status.py and 2 other locations - About 1 hr to fix
gecoscc/views/report_storages.py on lines 128..131
gecoscc/views/report_storages.py on lines 159..162

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

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=status", "format=html"))
def report_status_html(context, request):
    return report_status(context, request, 'html')
Severity: Major
Found in gecoscc/views/report_status.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_computer_users.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_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

There are no issues that match your filters.

Category
Status