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.
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];
- Read upRead up
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];
ThumcnoServer
has 40 functions (exceeds 20 allowed). Consider refactoring. Open
class ThumcnoServer
{
public $src = '';
public $is404 = false;
public $docRoot = '';
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.');
- Read upRead up
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);
- Read upRead up
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);
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.');
- Read upRead up
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;
- Read upRead up
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.');
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)) {
- Read upRead up
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)) {
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()) {
- Read upRead up
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;
- Read upRead up
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');
- Read upRead up
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;
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');
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);
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'];
- Read upRead up
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.");