tacnoman/thumcno

View on GitHub

Showing 55 of 55 total issues

Method cleanCache has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function cleanCache()
    {
        $config = Config::getInstance();
        if ($config->appConfigs['file_cache_time_between_cleans'] < 0) {
            return;
Severity: Minor
Found in src/Tacnoman/ThumcnoServer.php - About 1 hr to fix

    Function run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function run()
        {
            $config = Config::getInstance();
            if ($this->isURL) {
                if (!$config->appConfigs['allow_external']) {
    Severity: Minor
    Found in src/Tacnoman/ThumcnoServer.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 tryServerCache has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function tryServerCache()
        {
            $config = Config::getInstance();
            Logger::info('Trying server cache');
            if (file_exists($this->cachefile)) {
    Severity: Minor
    Found in src/Tacnoman/ThumcnoServer.php - About 1 hr to fix

      Method serveExternalImage has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function serveExternalImage()
          {
              if (!preg_match('/^https?:\/\/[a-zA-Z0-9\-\.]+/i', $this->src)) {
                  $this->error('Invalid URL supplied.');
      
      
      Severity: Minor
      Found in src/Tacnoman/ThumcnoServer.php - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                if ($imgType == 'png' && OPTIPNG_ENABLED && OPTIPNG_PATH && @is_file(OPTIPNG_PATH)) {
                    $exec = OPTIPNG_PATH;
                    Logger::debug("optipng'ing $tempfile");
                    $presize = filesize($tempfile);
                    $out = `$exec -o1 $tempfile`; //you can use up to -o7 but it really slows things down
        Severity: Major
        Found in src/Tacnoman/ThumcnoServer.php - About 1 hr to fix

          Function calcDocRoot has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function calcDocRoot()
              {
                  $docRoot = @$_SERVER['DOCUMENT_ROOT'];
                  if (defined('LOCAL_FILE_BASE_DIRECTORY')) {
                      $docRoot = LOCAL_FILE_BASE_DIRECTORY;
          Severity: Minor
          Found in src/Tacnoman/ThumcnoServer.php - About 55 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

          Function setCacheDirectory has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function setCacheDirectory()
              {
                  $config = Config::getInstance();
                  if ($config->appConfigs['file_cache_directory']) {
                      if (!is_dir($config->appConfigs['file_cache_directory'])) {
          Severity: Minor
          Found in src/Tacnoman/ThumcnoServer.php - About 55 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

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

              protected function serveWebshot()
              {
                  Logger::notice('Starting serveWebshot');
                  $instr = 'Please follow the instructions at http://code.google.com/p/timthumb/ to set your server up for taking website screenshots.';
                  if (!is_file(WEBSHOT_CUTYCAPT)) {
          Severity: Minor
          Found in src/Tacnoman/ThumcnoServer.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

          Avoid too many return statements within this method.
          Open

                              return $real;
          Severity: Major
          Found in src/Tacnoman/ThumcnoServer.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return false;
            Severity: Major
            Found in src/Tacnoman/ThumcnoServer.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return LogLevel::ERROR;
              Severity: Major
              Found in src/Tacnoman/Logger.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return false;
                Severity: Major
                Found in src/Tacnoman/ThumcnoServer.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              case 5: return LogLevel::WARNING;
                  Severity: Major
                  Found in src/Tacnoman/Logger.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return $this->error('Could not get a lock for writing.');
                    Severity: Major
                    Found in src/Tacnoman/ThumcnoServer.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return false;
                      Severity: Major
                      Found in src/Tacnoman/ThumcnoServer.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    case 6: return LogLevel::NOTICE;
                        Severity: Major
                        Found in src/Tacnoman/Logger.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return false;
                          Severity: Major
                          Found in src/Tacnoman/ThumcnoServer.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        case 8: return LogLevel::DEBUG;
                            Severity: Major
                            Found in src/Tacnoman/Logger.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return true;
                              Severity: Major
                              Found in src/Tacnoman/ThumcnoServer.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return true;
                                Severity: Major
                                Found in src/Tacnoman/ThumcnoServer.php - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language