deep-web-solutions/wordpress-framework-core

View on GitHub
src/includes/Functionalities/InstallationFunctionality.php

Summary

Maintainability
B
6 hrs
Test Coverage

Method install_or_update has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function install_or_update(): ?InstallFailureException {
        if ( ! Users::has_capabilities( 'activate_plugins' ) ) {
            return new InstallFailureException( 'User does not have enough permissions to run the installation routine' );
        }

Severity: Minor
Found in src/includes/Functionalities/InstallationFunctionality.php - About 1 hr to fix

    Method output_installation_js has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function output_installation_js() {
            if ( false === $this->has_notice_output ) {
                return; // The installation/upgrade notice has not been outputted.
            }
    
    
    Severity: Minor
    Found in src/includes/Functionalities/InstallationFunctionality.php - About 1 hr to fix

      Function get_installable_versions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function get_installable_versions(): array {
              $installable_versions = array();
      
              foreach ( \get_declared_classes() as $declared_class ) {
                  if ( ! \is_a( $declared_class, InstallableInterface::class, true ) ) {
      Severity: Minor
      Found in src/includes/Functionalities/InstallationFunctionality.php - About 1 hr 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

      Method register_admin_notices has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function register_admin_notices( AdminNoticesService $notices_service ): void {
              if ( \doing_action( 'activate_' . $this->get_plugin()->get_plugin_file_path() ) ) {
                  return;
              }
      
      
      Severity: Minor
      Found in src/includes/Functionalities/InstallationFunctionality.php - About 1 hr to fix

        Function uninstall has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function uninstall(): ?UninstallFailureException {
                if ( ! Users::has_capabilities( (array) 'delete_plugins' ) ) {
                    return new UninstallFailureException( 'User does not have enough permissions to run the uninstallation routine' );
                }
        
        
        Severity: Minor
        Found in src/includes/Functionalities/InstallationFunctionality.php - About 45 mins 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

        There are no issues that match your filters.

        Category
        Status