File SpotPage_newznabapi.php
has 887 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
class SpotPage_newznabapi extends SpotPage_Abs
{
private $_params;
Function search
has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring. Open
public function search($outputtype)
{
// Check users' permissions
$this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_perform_search, '');
- 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 showResults
has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring. Open
public function showResults($spots, $offset, $outputtype)
{
$nzbhandling = $this->_currentSession['user']['prefs']['nzbhandling'];
if ($outputtype == 'json') {
- 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 search
has 176 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function search($outputtype)
{
// Check users' permissions
$this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_perform_search, '');
Method showResults
has 150 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showResults($spots, $offset, $outputtype)
{
$nzbhandling = $this->_currentSession['user']['prefs']['nzbhandling'];
if ($outputtype == 'json') {
Method spotAcat2nabcat
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function spotAcat2nabcat()
{
return [0 => // Cat0 - Image
[0 => // Z0 - Movie
[0 => '2000|2030',
Method spotDetails
has 114 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function spotDetails($outputtype)
{
if (empty($this->_params['messageid'])) {
$this->showApiError(200);
Method caps
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function caps($outputtype)
{
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
Function showApiError
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function showApiError($errcode = 42)
{
switch ($errcode) {
case 100: $errtext = 'Incorrect user credentials';
break;
- 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 spotDetails
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function spotDetails($outputtype)
{
if (empty($this->_params['messageid'])) {
$this->showApiError(200);
- 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 categories
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function categories()
{
return [
['name' => 'Console',
'cat' => '1000',
Method showApiError
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showApiError($errcode = 42)
{
switch ($errcode) {
case 100: $errtext = 'Incorrect user credentials';
break;
Function Cat2NewznabCat
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function Cat2NewznabCat($hcat, $cat, $catZ)
{
$catList = explode('|', $cat);
$cat = $catList[0];
$nr = substr($cat, 1);
- 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 nabcat2spotcat
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function nabcat2spotcat($cat)
{
switch ($cat) {
case 1000: return 'cat2_a3,cat2_a4,cat2_a5,cat2_a6,cat2_a7,cat2_a8,cat2_a9,cat2_a10,cat2_a11,cat2_a12';
case 1010: return 'cat2_a10';
Method Cat2NewznabCat
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function Cat2NewznabCat($hcat, $cat, $catZ)
{
$catList = explode('|', $cat);
$cat = $catList[0];
$nr = substr($cat, 1);
Method render
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render()
{
// Don't let this output be cached
$this->sendExpireHeaders(true);
Function render
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function render()
{
// Don't let this output be cached
$this->sendExpireHeaders(true);
- 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 caps
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function caps($outputtype)
{
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
- 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
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
case 7020: return 'cat0_z2';
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
case 3030: return 'cat1_z3';
Avoid too many return
statements within this method. Open
case 5030: return 'cat0_z1_a0,cat0_z1_a1,cat0_z1_a2,cat0_z1_a3,cat0_z1_a10,cat0_z1_d';
Avoid too many return
statements within this method. Open
case 5050: return 'cat0_z1,cat0_z1_d';
Avoid too many return
statements within this method. Open
case 4040: return 'cat3_a4,cat3_a5,cat3_a6,cat3_a7';
Avoid too many return
statements within this method. Open
case 1060: return 'cat2_a7';
Avoid too many return
statements within this method. Open
case 4000: return 'cat3';
Avoid too many return
statements within this method. Open
case 5040: return 'cat0_z1_a4,cat0_z1_a6,cat0_z1_a7,cat0_z1_a8,cat0_z1_a9,cat0_z1_a14,cat0_z1_a15,cat0_z1_d';
Avoid too many return
statements within this method. Open
case 3010: return 'cat1_a0';
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
case 1050: return 'cat2_a7';
Avoid too many return
statements within this method. Open
case 2050: return 'cat0_z0_a6'; // Movies/BluRay
Avoid too many return
statements within this method. Open
case 2030: return 'cat0_z0_a0,cat0_z0_a1,cat0_z0_a2,cat0_z0_a3,cat0_z0_a10'; // Movies/SD
Avoid too many return
statements within this method. Open
case 3040: return 'cat1_a2,cat1_a4,cat1_a7,cat1_a8';
Avoid too many return
statements within this method. Open
case 6020: return 'cat0_z3_a1,cat0_z3_a8';
Avoid too many return
statements within this method. Open
return '';
Avoid too many return
statements within this method. Open
case 6030: return 'cat0_z3_a0';
Avoid too many return
statements within this method. Open
case 3020: return 'cat0_d13';
Avoid too many return
statements within this method. Open
case 4050: return 'cat2_a';
Avoid too many return
statements within this method. Open
case 5000: return 'cat0_z1,cat0_z1_d';
Avoid too many return
statements within this method. Open
case 5020: return 'cat0_z1,cat0_z1_d';
Avoid too many return
statements within this method. Open
case 6040: return 'cat0_z3_a4,cat0_z3_a6,cat0_z3_a7,cat0_z3_a8,cat0_z3_a9';
Avoid too many return
statements within this method. Open
case 6010: return 'cat0_z3_a3,cat0_z3_a10';
Avoid too many return
statements within this method. Open
case 5060: return 'cat0_z1_d18';
Avoid too many return
statements within this method. Open
case 1040: return 'cat2_a6';
Avoid too many return
statements within this method. Open
case 2000: return 'cat0_z0';
Avoid too many return
statements within this method. Open
case 3000: return 'cat1_a';
Avoid too many return
statements within this method. Open
case 5070: return 'cat0_z1_d29';
Avoid too many return
statements within this method. Open
case 6000: return 'cat0_z3';
Avoid too many return
statements within this method. Open
case 2040: return 'cat0_z0_a4,cat0_z0_a7,cat0_z0_a8,cat0_z0_a9'; // Movies/HD
Avoid too many return
statements within this method. Open
case 2060: return 'cat0_z0_a14'; // Movies/3D
Avoid too many return
statements within this method. Open
case 4020: return 'cat3_a0';
Avoid too many return
statements within this method. Open
case 4030: return 'cat3_a1';
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($nabCat[0] != '' && is_numeric($nabCat[0])) {
$attr = $doc->createElement('newznab:attr');
$attr->setAttribute('name', 'category');
$attr->setAttribute('value', $nabCat[0]);
$item->appendChild($attr);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 128.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($nabCat[0] != '' && is_numeric($nabCat[0])) {
$attr = $doc->createElement('newznab:attr');
$attr->setAttribute('name', 'category');
$attr->setAttribute('value', $nabCat[0]);
$item->appendChild($attr);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 128.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (($found == false) and ($this->_params['tvmazeid'] != '')) {
if (!preg_match('/^[0-9]{1,6}$/', $this->_params['tvmazeid'])) {
$this->showApiError(201);
return;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 122.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (($found == false) and ($this->_params['rid'] != '')) {
// validate input
if (!preg_match('/^[0-9]{1,6}$/', $this->_params['rid'])) {
$this->showApiError(201);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 122.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
2 => // Cat2 - Games
[0 => '4000|4050',
1 => '4000|4030',
2 => 'TUX',
3 => 'PS',
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 101.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76