howardjones/network-weathermap

View on GitHub
lib/Weathermap/CLI/Runner.php

Summary

Maintainability
B
6 hrs
Test Coverage

File Runner.php has 285 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Weathermap\CLI;

use GetOpt\GetOpt;
Severity: Minor
Found in lib/Weathermap/CLI/Runner.php - About 2 hrs to fix

    Method outputHTML has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function outputHTML()
        {
            if ($this->htmlFile != '') {
                MapUtility::debug("Writing HTML to $this->htmlFile\n");
    
    
    Severity: Minor
    Found in lib/Weathermap/CLI/Runner.php - About 1 hr to fix

      Method translateRuntimeOptionsToSettings has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function translateRuntimeOptionsToSettings()
          {
              global $weathermap_error_suppress;
      
              $this->configFile = $this->getOpt->getOption('config');
      Severity: Minor
      Found in lib/Weathermap/CLI/Runner.php - About 1 hr to fix

        Function translateRuntimeOptionsToSettings has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            private function translateRuntimeOptionsToSettings()
            {
                global $weathermap_error_suppress;
        
                $this->configFile = $this->getOpt->getOption('config');
        Severity: Minor
        Found in lib/Weathermap/CLI/Runner.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

        Define a constant instead of duplicating this literal "no-warn" 3 times.
        Open

                    Option::create(null, 'no-warn', GetOpt::REQUIRED_ARGUMENT)
        Severity: Critical
        Found in lib/Weathermap/CLI/Runner.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "sizedebug" 4 times.
        Open

                    Option::create(null, 'sizedebug', GetOpt::NO_ARGUMENT)
        Severity: Critical
        Found in lib/Weathermap/CLI/Runner.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "filename" 5 times.
        Open

                            ->setArgumentName('filename')
        Severity: Critical
        Found in lib/Weathermap/CLI/Runner.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "dump-json" 3 times.
        Open

                    Option::create(null, 'dump-json', GetOpt::REQUIRED_ARGUMENT)
        Severity: Critical
        Found in lib/Weathermap/CLI/Runner.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "debugging" 4 times.
        Open

                    $this->optionsOutput['debugging'] = true;
        Severity: Critical
        Found in lib/Weathermap/CLI/Runner.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "dump-config" 3 times.
        Open

                    Option::create(null, 'dump-config', GetOpt::REQUIRED_ARGUMENT)
        Severity: Critical
        Found in lib/Weathermap/CLI/Runner.php by sonar-php

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        There are no issues that match your filters.

        Category
        Status