Showing 130 of 217 total issues
File view.py
has 1274 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
"""
LEGION (https://shanewilliamscott.com)
Copyright (c) 2024 Shane Scott
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 run
has a Cognitive Complexity of 125 (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)
- 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
File controller.py
has 748 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
"""
LEGION (https://shanewilliamscott.com)
Copyright (c) 2024 Shane Scott
View
has 113 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, app, loop):
QtCore.QObject.__init__(self)
File dialogs.py
has 603 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
"""
LEGION (https://shanewilliamscott.com)
Copyright (c) 2024 Shane Scott
Function setupLayout
has 216 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.WindowType.Window | Qt.WindowType.WindowSystemMenuHint | Qt.WindowType.WindowMinimizeButtonHint | Qt.WindowType.WindowMaximizeButtonHint | \
Qt.WindowType.WindowCloseButtonHint
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()
Function handleHostAction
has a Cognitive Complexity of 43 (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)
- 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 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.ItemDataRole.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
- 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
Controller
has 73 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):
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)
- 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 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 handleServiceNameAction
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def handleServiceNameAction(self, targets, actions, action, restoring=True):
if action.text() == 'Take screenshot':
for ip in targets:
url = ip[0] + ':' + ip[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 data
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def data(self, index, role):
if role == QtCore.Qt.ItemDataRole.DisplayRole or role == QtCore.Qt.ItemDataRole.EditRole: # how to display each cell
value = ''
row = index.row()
column = index.column()
- 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 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)
- 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 runToolsFor
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def runToolsFor(self, service, hostname, ip, port, protocol='tcp'):
log.info('Running tools for: ' + service + ' on ' + ip + ':' + port)
if service.endswith("?"): # when nmap is not sure it will append a ?, so we need to remove it
service=service[:-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
File gui.py
has 337 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
"""
LEGION (https://shanewilliamscott.com)
Copyright (c) 2024 Shane Scott
Function data
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def data(self, index, role):
if role == QtCore.Qt.ItemDataRole.DecorationRole: # to show the open/closed/filtered icons
if index.column() == 0 or index.column() == 2:
tmp_state = self.__services[index.row()]['state']
- 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)