Showing 227 of 227 total issues
Method buildMainMenu
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function buildMainMenu(NodeController $nodeController)
{
$this->buildGenericNode('mainMenu', $nodeController)
->saySound('pp/3')
->maxAttemptsForInput(3)
Method init
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function init()
{
$this->logger->info('Init');
$this->agi = $this->getAgi();
$this->asteriskLogger = $this->agi->getAsteriskLogger();
The class Node has 29 fields. Consider redesigning Node to keep the number of fields under 15. Open
class Node
{
/**
* Any of the available DTMF digits in a classic telephone.
* @var string
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Method callClientMethods
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function callClientMethods($methods, $stopWhen = null)
{
$client = $this->getClient();
$logger = $client->getLogger();
$result = null;
Function validate
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function validate()
{
foreach ($this->inputValidations as $name => $data) {
$validator = $data['callback'];
$result = $validator($this);
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
$variables = array(
'request' => 'request.php',
'channel' => 'SIP/blah-00803890',
'language' => 'ar',
'type' => 'SIP',
- 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 108.
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
$variables = array(
'request' => 'request.php',
'channel' => 'SIP/blah-00803890',
'language' => 'ar',
'type' => 'SIP',
- 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 108.
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
Method getCommonCallingCardValidations
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getCommonCallingCardValidations()
{
return array(
'cardExists' => Node::createValidatorInfo(
function(Node $node) {
Method spool
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function spool(CallFile $call, $schedule = null)
{
$filename = tempnam($this->tmpDir, 'PAGICallFile');
if ($filename === false) {
throw new CallSpoolException('Could generate temporary filename');
The class AbstractClient has 55 public methods and attributes. Consider reducing the number of public items to less than 45. Open
abstract class AbstractClient implements IClient
{
/**
* PSR-3 logger.
* @var LoggerInterface
- Read upRead up
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
The class MockedClientImpl has 60 public methods and attributes. Consider reducing the number of public items to less than 45. Open
class MockedClientImpl extends AbstractClient
{
/**
* Mocked result strings.
* @var string[]
- Read upRead up
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
The class Node has 48 public methods and attributes. Consider reducing the number of public items to less than 45. Open
class Node
{
/**
* Any of the available DTMF digits in a classic telephone.
* @var string
- Read upRead up
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
Method processNodeResult
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function processNodeResult(Node $node)
{
$ret = false;
$name = $node->getName();
if (isset($this->nodeResults[$name])) {
Method sayInterruptable
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function sayInterruptable($what, array $arguments)
{
$client = $this->getClient();
$logger = $client->getLogger();
Function callClientMethods
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function callClientMethods($methods, $stopWhen = null)
{
$result = null;
foreach ($methods as $callInfo) {
foreach ($callInfo as $name => $arguments) {
- 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 buildConfirmTransferToCard
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function buildConfirmTransferToCard(
NodeController $nodeController, \Closure $onInit
) {
$this->buildGenericNode('confirmTransferToCard', $nodeController)
->cancelWith(Node::DTMF_STAR)
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class MyPAGIApplication extends PAGIApplication
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class MyPagiApplication extends PAGIApplication
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class MyPagiApplication extends PAGIApplication
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Card
- Exclude checks