File settingsDialog.py
has 1253 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
"""
LEGION (https://shanewilliamscott.com)
Copyright (c) 2024 Shane Scott
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
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)
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)
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()
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
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
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
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
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.SelectionBehavior.SelectRows)
self.toolForHostsTableWidget.setFixedWidth(180)
self.toolForHostsTableWidget.setShowGrid(False) # to make the cells of the table read only
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()
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()
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')
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
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()
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)
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
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())
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())
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
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
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
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"