GoVanguard/legion

View on GitHub

Showing 128 of 209 total issues

File settingsDialog.py has 1253 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python

"""
LEGION (https://govanguard.com)
Copyright (c) 2020 GoVanguard
Severity: Major
Found in ui/settingsDialog.py - About 3 days to fix

File view.py has 1240 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python

"""
LEGION (https://govanguard.com)
Copyright (c) 2020 GoVanguard
Severity: Major
Found in ui/view.py - About 3 days to fix

Function run has a Cognitive Complexity of 123 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self):
        try:
            self.updateProgressObservable.start()
            session = self.db.session()
            self.tsLog("Parsing nmap xml file: " + self.filename)
Severity: Minor
Found in app/importers/NmapImporter.py - About 2 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 controller.py has 703 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
"""
LEGION (https://govanguard.com)
Copyright (c) 2020 GoVanguard

Severity: Major
Found in controller/controller.py - About 1 day to fix

View has 111 functions (exceeds 50 allowed). Consider refactoring.
Open

class View(QtCore.QObject):
    tick = QtCore.pyqtSignal(int, name="changed")                       # signal used to update the progress bar
    
    def __init__(self, viewState: ViewState, ui, ui_mainwindow, shell: Shell):
        QtCore.QObject.__init__(self)
Severity: Major
Found in ui/view.py - About 1 day to fix

File dialogs.py has 603 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
"""
LEGION (https://govanguard.com)
Copyright (c) 2020 GoVanguard

Severity: Major
Found in ui/dialogs.py - About 1 day to fix

Function setupLayout has 215 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setupLayout(self):
        self.setModal(True)
        self.setWindowTitle('Add host(s) to scan seperated by semicolons')
        flags = Qt.Window | Qt.WindowSystemMenuHint | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint | \
                Qt.WindowCloseButtonHint
Severity: Major
Found in ui/addHostDialog.py - About 1 day to fix

Function setupLayout has 189 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setupLayout(self):
        self.HostStatusLabel = QtWidgets.QLabel()

        self.HostStateLabel = QtWidgets.QLabel()
        self.HostStateText = QtWidgets.QLabel()
Severity: Major
Found in ui/dialogs.py - About 7 hrs to fix

Function data has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    def data(self, index, role):                # this method takes care of how the information is displayed
        if role == QtCore.Qt.DecorationRole:    # to show the operating system icon instead of text
            if index.column() == 1:                                     # if trying to display the operating system
                os_string = self.__hosts[index.row()]['osMatch']
                if os_string == '':             # if there is no OS information, use the question mark icon
Severity: Minor
Found in ui/models/hostmodels.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

Controller has 71 functions (exceeds 50 allowed). Consider refactoring.
Open

class Controller:

    # initialisations that will happen once - when the program is launched
    @timing
    def __init__(self, view, logic):
Severity: Major
Found in controller/controller.py - About 5 hrs to fix

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

    def contextMenuServiceNamesTableView(self, pos):
        if len(self.ui.ServiceNamesTableView.selectionModel().selectedRows()) > 0:
            row = self.ui.ServiceNamesTableView.selectionModel().selectedRows()[len(
                self.ui.ServiceNamesTableView.selectionModel().selectedRows())-1].row()
            self.viewState.service_clicked = self.ServiceNamesTableModel.getServiceNameForRow(row)
Severity: Minor
Found in ui/view.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

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

    def validateCurrentTab(self, tab):
        validationPassed = True
        if tab == 'General':
            if not self.validateGeneralTab():
                self.settingsTabWidget.setCurrentIndex(0)
Severity: Minor
Found in ui/settingsDialog.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

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

    def handleHostAction(self, ip, hostid, actions, action):
        repositoryContainer = self.logic.activeProject.repositoryContainer

        if action.text() == 'Mark as checked' or action.text() == 'Mark as unchecked':
            repositoryContainer.hostRepository.toggleHostCheckStatus(ip)
Severity: Minor
Found in controller/controller.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

Function sort has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def sort(self, Ncol, order):
        self.layoutAboutToBeChanged.emit()
        array = []
        
        if Ncol == 0:                                                   # if sorting by ip (and by default)
Severity: Minor
Found in ui/models/servicemodels.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

Function data has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def data(self, index, role):
        if role == QtCore.Qt.DisplayRole or role == QtCore.Qt.EditRole: # how to display each cell
            value = ''
            row = index.row()
            column = index.column()
Severity: Minor
Found in ui/models/processmodels.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

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

#!/usr/bin/env python
"""
LEGION (https://govanguard.com)
Copyright (c) 2020 GoVanguard

Severity: Minor
Found in ui/gui.py - About 4 hrs to fix

Function data has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def data(self, index, role):
        if role == QtCore.Qt.DecorationRole:                            # to show the open/closed/filtered icons
            if index.column() == 0 or index.column() == 2:
                tmp_state = self.__services[index.row()]['state']

Severity: Minor
Found in ui/models/servicemodels.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

Function setupTerminalCommandsTab has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setupTerminalCommandsTab(self):
        self.actionTerminalLabel = QtWidgets.QLabel()
        self.actionTerminalLabel.setText('Tools')
        
        self.toolForTerminalTableWidget = QtWidgets.QTableWidget(self.portTerminalActionsWidget)
Severity: Major
Found in ui/settingsDialog.py - About 4 hrs to fix

Function setupPortCommandsTab has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setupPortCommandsTab(self):
        self.label11 = QtWidgets.QLabel()
        self.label11.setText('Tools')

        self.toolForServiceTableWidget = QtWidgets.QTableWidget(self.PortActionsWidget)
Severity: Major
Found in ui/settingsDialog.py - About 4 hrs to fix

AddSettingsDialog has 60 functions (exceeds 50 allowed). Consider refactoring.
Open

class AddSettingsDialog(QtWidgets.QDialog):  # dialog shown when the user selects settings menu
    def __init__(self, shell: Shell, parent=None):
        QtWidgets.QDialog.__init__(self, parent)

        self.setupLayout()
Severity: Major
Found in ui/settingsDialog.py - About 3 hrs to fix
Severity
Category
Status
Source
Language