fau-fablab/FabLabKasse

View on GitHub

Showing 88 of 88 total issues

File kassenbuch.py has 1556 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# PYTHON_ARGCOMPLETE_OK


Severity: Major
Found in FabLabKasse/kassenbuch.py - About 4 days to fix

Function main has a Cognitive Complexity of 149 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    """parse args, run the desired action"""
    args = parse_args()

    # go to script dir (configs are relative path names)
Severity: Minor
Found in FabLabKasse/kassenbuch.py - About 3 days 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

File gui.py has 782 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# FabLabKasse, a Point-of-Sale Software for FabLabs and other public and trust-based workshops.
# Copyright (C) 2015  Julian Hammer <julian.hammer@fablab.fau.de>
Severity: Major
Found in FabLabKasse/gui.py - About 1 day to fix

File FAUcardPaymentThread.py has 592 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#

from __future__ import print_function
Severity: Major
Found in FabLabKasse/faucardPayment/FAUcardPaymentThread.py - About 1 day to fix

File abstract.py has 425 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# FabLabKasse, a Point-of-Sale Software for FabLabs and other public and trust-based workshops.
# Copyright (C) 2013-2015 Julian Hammer <julian.hammer@fablab.fau.de>
#                         Maximilian Gaukler <max@fablab.fau.de>
Severity: Minor
Found in FabLabKasse/shopping/backend/abstract.py - About 6 hrs to fix

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

    if len(sys.argv) == 3:
        dateFrom = datetime.datetime.strptime(sys.argv[1], "%Y-%m-%d")
        dateTo = datetime.datetime.strptime(sys.argv[2], "%Y-%m-%d")
        print("filtering from {0} to {1}".format(dateFrom, dateTo))
        rechnungen = filter(lambda r: dateFrom < r.datum < dateTo, rechnungen)
FabLabKasse/shopping/backend/legacy_offline_kassenbuch_tools/exportConsumptionMoney.py on lines 180..184

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

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

    if len(sys.argv) == 3:
        dateFrom = datetime.datetime.strptime(sys.argv[1], "%Y-%m-%d")
        dateTo = datetime.datetime.strptime(sys.argv[2], "%Y-%m-%d")
        print("filtering from {0} to {1}".format(dateFrom, dateTo))
        rechnungen = filter(lambda r: dateFrom < r.datum < dateTo, rechnungen)
FabLabKasse/shopping/backend/legacy_offline_kassenbuch_tools/exportConsumptionMoney.py on lines 232..236

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

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

Function main has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    os.chdir(os.path.dirname(os.path.realpath(__file__)) + "/../")

    def isWarningLine(line):
        return "CRITICAL" in line or "ERROR" in line or "WARN" in line
Severity: Minor
Found in FabLabKasse/scripts/logWatchAndCleanup.py - About 5 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

File offline_base.py has 358 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""basic functionality for offline backends

use case:
- categories and products are only loaded once at startup and then kept RAM for the whole application time.
- the carts are stored in RAM
Severity: Minor
Found in FabLabKasse/shopping/backend/offline_base.py - About 4 hrs to fix

Function aggregate_consumption has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

def aggregate_consumption(rechnungen):
    """Returns consumption from given rechnungen"""
    consumption = {}
    consumptionUnits = {}
    name = {}

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 _decrease_balance has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def _decrease_balance(self) -> int:
        """
        Decreases card balance by self.amount_cents by following steps:
        0. If user aborted: Quit by raising UserAbortionError.
        1. Try to decrease balance
Severity: Minor
Found in FabLabKasse/faucardPayment/FAUcardPaymentThread.py - About 3 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

File generateLog.py has 299 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3


import sys
import os
Severity: Minor
Found in FabLabKasse/faucardPayment/generateLog.py - About 3 hrs to fix

AbstractShoppingBackend has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class AbstractShoppingBackend(object):

    """manages products, categories and orders (cart)"""

    __metaclass__ = ABCMeta
Severity: Minor
Found in FabLabKasse/shopping/backend/abstract.py - About 3 hrs to fix

Function main has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    SHUTDOWN_LOCKFILE = "/tmp/fablabkasse-shutdown"
    while file_exists(SHUTDOWN_LOCKFILE):
        # This is a workaround for bug https://github.com/spanezz/nodm/issues/5 in the nodm display manager.
        # The lockfile must be in /tmp and not in /run/user because is cleared early during shutdown.
Severity: Minor
Found in run.py - About 3 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

Function printFilteredFreiePreiseingabe has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def printFilteredFreiePreiseingabe(rechnungen, searchwords):
        summe = 0
        for r in rechnungen:
            for p in r.positionen:
                if p["produkt_ref"] != "9997":

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

File pxss.py has 293 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# Copyright 2009 Yu-Jie Lin
# Copyright 2003 David McClosky
#
# This code is licensed under the GPLv3
Severity: Minor
Found in FabLabKasse/libs/pxss/pxss.py - About 3 hrs to fix

AbstractOfflineShoppingBackend has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

class AbstractOfflineShoppingBackend(AbstractShoppingBackend):

    """manages products, categories and orders (cart)"""

    __metaclass__ = ABCMeta
Severity: Minor
Found in FabLabKasse/shopping/backend/offline_base.py - About 3 hrs to fix

File ClientDialogCode.py has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
#
# FabLabKasse, a Point-of-Sale Software for FabLabs and other public and trust-based workshops.
# Copyright (C) 2015  Julian Hammer <julian.hammer@fablab.fau.de>
#                     Maximilian Gaukler <max@fablab.fau.de>
Severity: Minor
Found in FabLabKasse/UI/ClientDialogCode.py - About 2 hrs to fix

File exportConsumptionMoney.py has 284 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# FabLabKasse, a Point-of-Sale Software for FabLabs and other public and trust-based workshops.
# Copyright (C) 2014  Julian Hammer <julian.hammer@fablab.fau.de>

File payment_methods.py has 273 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
#
# FabLabKasse, a Point-of-Sale Software for FabLabs and other public and trust-based workshops.
# Copyright (C) 2015  Julian Hammer <julian.hammer@fablab.fau.de>
#                     Maximilian Gaukler <max@fablab.fau.de>
Severity: Minor
Found in FabLabKasse/shopping/payment_methods.py - About 2 hrs to fix
Severity
Category
Status
Source
Language