gecos-team/gecoscc-ui

View on GitHub
gecoscc/views/report_printers.py

Summary

Maintainability
F
3 days
Test Coverage

Function report_printers has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

def report_printers(context, request, file_ext):
    '''
    Generate a report with all the printers and its related computers.

    
Severity: Minor
Found in gecoscc/views/report_printers.py - About 1 day 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

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

            for computer in related_computers:
                full_path = computer['path'] + '.' + computer['name']
                if not full_path in computer_paths:
                    computer_paths.append(full_path)
                    computers.append(computer)
Severity: Major
Found in gecoscc/views/report_printers.py and 1 other location - About 3 hrs to fix
gecoscc/views/report_printers.py on lines 151..155

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

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

            for computer in related_computers:
                full_path = computer['path'] + '.' + computer['name']
                if not full_path in computer_paths:
                    computer_paths.append(full_path)
                    computers.append(computer)
Severity: Major
Found in gecoscc/views/report_printers.py and 1 other location - About 3 hrs to fix
gecoscc/views/report_printers.py on lines 109..113

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

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=printers", "format=pdf"))
def report_printers_pdf(context, request):
    filename = 'report_printers.pdf'
Severity: Major
Found in gecoscc/views/report_printers.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_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='csv',
             permission='edit',
             request_param=("type=printers", "format=csv"))
def report_printers_csv(context, request):
    filename = 'report_printers.csv'
Severity: Major
Found in gecoscc/views/report_printers.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 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 2 locations. Consider refactoring.
Open

    rows = sorted(rows, key = lambda i: (i[0].lower(), i[1].lower(),
                                         i[6].lower()))   
Severity: Major
Found in gecoscc/views/report_printers.py and 1 other location - About 2 hrs to fix
gecoscc/views/report_storages.py on lines 180..181

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

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

    return {'headers': header,
            'rows': rows,
            'default_order': [[ 0, 'asc' ], [ 1, 'asc' ], [ 6, 'asc' ]],
            'widths': widths,
            'report_title': title,
Severity: Major
Found in gecoscc/views/report_printers.py and 1 other location - About 1 hr to fix
gecoscc/views/report_storages.py on lines 183..191

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

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

    header = (_(u'Path'),
              _(u'Name'),
              _(u'Manufacturer'),
              _(u'Model'),
              _(u'Serial number'),
Severity: Major
Found in gecoscc/views/report_printers.py and 1 other location - About 1 hr to fix
gecoscc/views/report_user.py on lines 97..111

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

@view_config(route_name='report_file', renderer='templates/report.jinja2',
             permission='edit',
             request_param=("type=printers", "format=html"))
def report_printers_html(context, request):
    return report_printers(context, request, 'html')
Severity: Major
Found in gecoscc/views/report_printers.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_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

There are no issues that match your filters.

Category
Status