tacnoman/thumcno

View on GitHub

Showing 55 of 55 total issues

File ThumcnoServer.php has 1131 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Tacnoman;

//These are now disabled by default because the file sizes of PNGs (and GIFs) are much smaller than we used to generate.
Severity: Major
Found in src/Tacnoman/ThumcnoServer.php - About 2 days to fix

    Function processImageAndWriteToCache has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function processImageAndWriteToCache($localImage)
        {
            $config = Config::getInstance();
            $sData = getimagesize($localImage);
            $origType = $sData[2];
    Severity: Minor
    Found in src/Tacnoman/ThumcnoServer.php - About 1 day 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 processImageAndWriteToCache has 249 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function processImageAndWriteToCache($localImage)
        {
            $config = Config::getInstance();
            $sData = getimagesize($localImage);
            $origType = $sData[2];
    Severity: Major
    Found in src/Tacnoman/ThumcnoServer.php - About 1 day to fix

      ThumcnoServer has 40 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class ThumcnoServer
      {
          public $src = '';
          public $is404 = false;
          public $docRoot = '';
      Severity: Minor
      Found in src/Tacnoman/ThumcnoServer.php - About 5 hrs to fix

        Function getLocalImagePath has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function getLocalImagePath($src)
            {
                $src = ltrim($src, '/'); //strip off the leading '/'
                if (!$this->docRoot) {
                    Logger::error('We have no document root set, so as a last resort, lets check if the image is in the current dir and serve that.');
        Severity: Minor
        Found in src/Tacnoman/ThumcnoServer.php - About 3 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 getURL has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function getURL($url, $tempfile)
            {
                $config = Config::getInstance();
                $this->lastURLError = false;
                $url = preg_replace('/ /', '%20', $url);
        Severity: Minor
        Found in src/Tacnoman/ThumcnoServer.php - About 3 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

        Method getURL has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function getURL($url, $tempfile)
            {
                $config = Config::getInstance();
                $this->lastURLError = false;
                $url = preg_replace('/ /', '%20', $url);
        Severity: Major
        Found in src/Tacnoman/ThumcnoServer.php - About 2 hrs to fix

          Function validateExternalImage has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function validateExternalImage()
              {
                  $config = Config::getInstance();
                  if ($this->isURL && (!$config->appConfigs['allow_external'])) {
                      $this->error('You are not allowed to fetch images from an external website.');
          Severity: Minor
          Found in src/Tacnoman/ThumcnoServer.php - About 2 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 cleanCache has a Cognitive Complexity of 17 (exceeds 5 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 2 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

          Method getLocalImagePath has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function getLocalImagePath($src)
              {
                  $src = ltrim($src, '/'); //strip off the leading '/'
                  if (!$this->docRoot) {
                      Logger::error('We have no document root set, so as a last resort, lets check if the image is in the current dir and serve that.');
          Severity: Major
          Found in src/Tacnoman/ThumcnoServer.php - About 2 hrs to fix

            Function tryServerCache has a Cognitive Complexity of 15 (exceeds 5 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

            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 serveWebshot has 46 lines of code (exceeds 25 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 1 hr to fix

              Function handleErrors has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function handleErrors()
                  {
                      if ($this->haveErrors()) {
                          $config = Config::getInstance();
                          if ($config->appConfigs['not_found_image'] && $this->is404()) {
              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

              Function execute has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function execute(InputInterface $input, OutputInterface $output)
                  {
                      $output->writeln('Checking configurations...');
                      $output->write(PHP_EOL);
                      $errors = 0;
              Severity: Minor
              Found in console/CheckCommand.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

              Function tryBrowserCache has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function tryBrowserCache()
                  {
                      $config = Config::getInstance();
                      if ($config->appConfigs['browser_cache_disable']) {
                          Logger::debug('Browser caching is disabled');
              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 execute has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function execute(InputInterface $input, OutputInterface $output)
                  {
                      $output->writeln('Checking configurations...');
                      $output->write(PHP_EOL);
                      $errors = 0;
              Severity: Minor
              Found in console/CheckCommand.php - About 1 hr to fix

                Method tryBrowserCache has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function tryBrowserCache()
                    {
                        $config = Config::getInstance();
                        if ($config->appConfigs['browser_cache_disable']) {
                            Logger::debug('Browser caching is disabled');
                Severity: Minor
                Found in src/Tacnoman/ThumcnoServer.php - About 1 hr to fix

                  Method execute has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function execute(InputInterface $input, OutputInterface $output)
                      {
                          $helper = $this->getHelper('question');
                  
                          $output->writeln(PHP_EOL);
                  Severity: Minor
                  Found in console/ConfigCommand.php - About 1 hr to fix

                    Function getIP has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function getIP()
                        {
                            $rem = @$_SERVER['REMOTE_ADDR'];
                            $ff = @$_SERVER['HTTP_X_FORWARDED_FOR'];
                            $ci = @$_SERVER['HTTP_CLIENT_IP'];
                    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 serveCacheFile has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function serveCacheFile()
                        {
                            Logger::notice("Serving {$this->cachefile}");
                            if (!is_file($this->cachefile)) {
                                $this->error("serveCacheFile called in thumcno but we couldn't find the cached file.");
                    Severity: Minor
                    Found in src/Tacnoman/ThumcnoServer.php - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language