File settingsDialog.py
has 1253 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
"""
LEGION (https://govanguard.com)
Copyright (c) 2022 GoVanguard
- Create a ticketCreate a ticket
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)
- Read upRead up
- Create a ticketCreate a ticket
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)
- Create a ticketCreate a ticket
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)
- Create a ticketCreate a ticket
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()
- Create a ticketCreate a ticket
Function updateToolForTerminalInformation
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def updateToolForTerminalInformation(self, update = True):
#if self.commandTabsValidate() == True:
if self.validateCommandTabs(self.terminalActionNameText, self.terminalLabelText, self.terminalCommandText):
# do not update anything the first time or when you remove a line
if self.terminalTableRow == -1 or update == False:
- Read upRead up
- Create a ticketCreate a ticket
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 updateToolForServiceInformation
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def updateToolForServiceInformation(self, update = True):
#if self.commandTabsValidate() == True:
if self.validateCommandTabs(self.portActionNameText, self.portLabelText, self.portCommandText):
# the first time do not update anything
if self.portTableRow == -1 or update == False:
- Read upRead up
- Create a ticketCreate a ticket
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 populateAutomatedAttacksTab
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def populateAutomatedAttacksTab(self): # TODO: this one is still to big and ugly. needs work.
self.typeDic = {}
for i in range(len(self.settings.portActions)):
# the dictionary contains the name, the text input and the layout for each tool
self.typeDic.update({self.settings.portActions[i][1]:[QtWidgets.QLabel(),QtWidgets.QLineEdit(),
- Read upRead up
- Create a ticketCreate a ticket
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 switchToolTabClick
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def switchToolTabClick(self): # TODO: check for duplicate code.
if self.ToolSettingsTab.tabText(self.ToolSettingsTab.currentIndex()) == 'Host Commands':
self.toolForHostsTableWidget.selectRow(0)
self.updateToolForHostInformation(False)
- Read upRead up
- Create a ticketCreate a ticket
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 setupHostCommandsTab
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setupHostCommandsTab(self):
self.toolForHostsTableWidget = QtWidgets.QTableWidget(self.HostActionsWidget)
self.toolForHostsTableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)
self.toolForHostsTableWidget.setFixedWidth(180)
self.toolForHostsTableWidget.setShowGrid(False) # to make the cells of the table read only
- Create a ticketCreate a ticket
Function setupGeneralTab
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setupGeneralTab(self):
self.terminalLabel = QtWidgets.QLabel()
self.terminalLabel.setText('Terminal')
self.terminalLabel.setFixedWidth(150)
self.terminalComboBox = QtWidgets.QComboBox()
- Create a ticketCreate a ticket
Function setupStagedNmapTab
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setupStagedNmapTab(self):
self.stage1label = QtWidgets.QLabel()
self.stage1label.setText('nmap stage 1')
self.stage1label.setFixedWidth(100)
self.stage1Input = QtWidgets.QLineEdit()
- Create a ticketCreate a ticket
Function setupBruteTab
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setupBruteTab(self):
self.vlayoutBrute = QtWidgets.QVBoxLayout(self.BruteSettingsTab)
self.label5 = QtWidgets.QLabel()
self.label5.setText('Username lists path')
- Create a ticketCreate a ticket
Function updateToolForHostInformation
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def updateToolForHostInformation(self, update = True):
#if self.commandTabsValidate() == True:
if self.validateCommandTabs(self.hostActionNameText, self.hostLabelText, self.hostCommandText):
# do not update any values the first time or when the remove button is clicked
- Read upRead up
- Create a ticketCreate a ticket
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 setupToolPathsTab
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setupToolPathsTab(self):
self.nmapPathlabel = QtWidgets.QLabel()
self.nmapPathlabel.setText('Nmap')
self.nmapPathlabel.setFixedWidth(100)
self.nmapPathInput = QtWidgets.QLineEdit()
- Create a ticketCreate a ticket
Function setupLayout
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setupLayout(self):
self.setModal(True)
self.setWindowTitle('Settings')
self.setFixedSize(900, 500)
- Create a ticketCreate a ticket
Function validateToolName
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validateToolName(self):
selectGroup = self.selectGroup()
tmpWidget = selectGroup[0]
tmplineEdit = selectGroup[1]
actions = selectGroup[4]
- Read upRead up
- Create a ticketCreate a ticket
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
Avoid deeply nested control flow statements. Open
if len(tool) == 4:
servicesList = tool[3].split(',')
self.terminalServicesActiveTable.setRowCount(len(servicesList))
for i in range(len(servicesList)):
self.terminalServicesActiveTable.setItem(i, 0, QtWidgets.QTableWidgetItem())
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if len(tool) == 4:
servicesList = tool[3].split(',')
self.terminalServicesActiveTable.setRowCount(len(servicesList))
for i in range(len(servicesList)):
self.terminalServicesActiveTable.setItem(i, 0, QtWidgets.QTableWidgetItem())
- Create a ticketCreate a ticket
Function selectGroup
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def selectGroup(self):
tabSelected = -1
if self.ToolSettingsTab.tabText(self.ToolSettingsTab.currentIndex()) == 'Host Commands':
tabSelected = 1
- Read upRead up
- Create a ticketCreate a ticket
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 updateSettings
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def updateSettings(self):
# LEO: reorganised stuff in a more logical way but no changes were made yet :)
# update GENERAL tab settings
self.settings.general_default_terminal = str(self.terminalComboBox.currentText())
self.settings.general_max_fast_processes = str(self.fastProcessesComboBox.currentText())
- Read upRead up
- Create a ticketCreate a ticket
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 validateUniqueToolName
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validateUniqueToolName(self, widget, tablerow, text):
if tablerow != -1:
for row in [i for i in range(widget.rowCount()) if i not in [tablerow]]:
if widget.item(row,0).text() == text:
return False
- Read upRead up
- Create a ticketCreate a ticket
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"