Hackman238/legion

View on GitHub

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
Severity: Major
Found in ui/view.py - About 3 days to fix

    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
    Severity: Major
    Found in ui/settingsDialog.py - About 3 days to fix

      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)
      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 748 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python
      """
      LEGION (https://shanewilliamscott.com)
      Copyright (c) 2024 Shane Scott
      
      
      Severity: Major
      Found in controller/controller.py - About 1 day to fix

        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)
        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://shanewilliamscott.com)
          Copyright (c) 2024 Shane Scott
          
          
          Severity: Major
          Found in ui/dialogs.py - About 1 day to fix

            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
            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 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)
                Severity: Minor
                Found in controller/controller.py - About 6 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 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
                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 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):
                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 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]
                  Severity: Minor
                  Found in controller/controller.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.ItemDataRole.DisplayRole or role == QtCore.Qt.ItemDataRole.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

                  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 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]
                  Severity: Minor
                  Found in controller/controller.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 337 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  #!/usr/bin/env python
                  """
                  LEGION (https://shanewilliamscott.com)
                  Copyright (c) 2024 Shane Scott
                  
                  
                  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.ItemDataRole.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
                      Severity
                      Category
                      Status
                      Source
                      Language