Showing 217 of 217 total issues
File view.py
has 1274 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
"""
LEGION (https://gotham-security.com)
Copyright (c) 2023 Gotham Security
- Create a ticketCreate a ticket
File settingsDialog.py
has 1253 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
"""
LEGION (https://gotham-security.com)
Copyright (c) 2023 Gotham Security
- Create a ticketCreate a ticket
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
- 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
File controller.py
has 748 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
"""
LEGION (https://gotham-security.com)
Copyright (c) 2023 Gotham Security
- Create a ticketCreate a ticket
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)
- Create a ticketCreate a ticket
File dialogs.py
has 603 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
"""
LEGION (https://gotham-security.com)
Copyright (c) 2023 Gotham Security
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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()
- Create a ticketCreate a ticket
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
- 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 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
- 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
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):
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Open
if not self.__services[row]['extrainfo'] == None and not self.__services[row]['extrainfo'] == '':
value = value + ' (' + self.__services[row]['extrainfo'] + ')'
- Read upRead up
- Create a ticketCreate a ticket
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 94.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if not self.__services[i]['extrainfo'] == None and not self.__services[i]['extrainfo'] == '':
value = value + ' (' + self.__services[i]['extrainfo'] + ')'
- Read upRead up
- Create a ticketCreate a ticket
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 94.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- 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 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if not self.__services[i]['version'] == None and not self.__services[i]['version'] == '':
value = value + ' ' + self.__services[i]['version']
- Read upRead up
- Create a ticketCreate a ticket
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 88.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if not self.__services[row]['version'] == None and not self.__services[row]['version'] == '':
value = value + ' ' + self.__services[row]['version']
- Read upRead up
- Create a ticketCreate a ticket
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 88.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- 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 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
- 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 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
- 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"