Showing 36 of 36 total issues
Method transactionalUp
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function transactionalUp(YoPdo $yo_pdo)
{
$sql = <<<SQL
CREATE SEQUENCE buffered_jobs_buffered_job_id_seq;
CREATE SEQUENCE failed_jobs_failed_job_id_seq;
- Create a ticketCreate a ticket
Method transactionalUp
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function transactionalUp(YoPdo $yo_pdo)
{
$sql = <<<SQL
CREATE TABLE scheduled_jobs
(
- Create a ticketCreate a ticket
Method addDefaultServices
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addDefaultServices($config_file = null)
{
$this->addConfigFileService($config_file);
$this['hodor.config.factory'] = $this->share(
- Create a ticketCreate a ticket
Avoid excessively long variable names like $job_options_validator. Keep variable name length under 20. Open
private $job_options_validator;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $adapter_factory_config. Keep variable name length under 20. Open
private $adapter_factory_config;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $config_loader_factory. Keep variable name length under 20. Open
$config_loader_factory = new LoaderFactory();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $adapter_factory_config. Keep variable name length under 20. Open
public function __construct(QueueConfig $queue_config, array $adapter_factory_config = [])
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Method processScheduledJobs
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processScheduledJobs()
{
$sql = <<<SQL
INSERT INTO buffered_jobs
(
- Create a ticketCreate a ticket
Avoid using short method names like Migration::up(). The configured minimum method name length is 3. Open
public function up()
{
/**
* @var $container Container
*/
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Avoid using short method names like PgsqlPhpmigAdapter::up(). The configured minimum method name length is 3. Open
public function up(Migration $migration)
{
$migration_reflection = new ReflectionClass(get_class($migration));
$this->yo_pdo->insert('migrations.migrations', [
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Method configure
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function configure()
{
$this
->setName('test:generate-config')
->setDescription('Generate a config file for tests')
- Create a ticketCreate a ticket
Method markJobAsFinished
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function markJobAsFinished($status, array $meta)
{
$sql = <<<SQL
SELECT *
FROM queued_jobs
- Create a ticketCreate a ticket
Method getJobsToRunGenerator
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getJobsToRunGenerator()
{
$this->processScheduledJobs();
$sql = <<<SQL
- Create a ticketCreate a ticket
Method transactionalUp
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function transactionalUp(YoPdo $yo_pdo)
{
$sql = <<<SQL
ALTER TABLE buffered_jobs
ADD COLUMN mutex_id VARCHAR DEFAULT 'hodor:' || currval('buffered_jobs_buffered_job_id_seq'::regclass);
- Create a ticketCreate a ticket
Method down
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function down(Migration $migration)
{
$version = $migration->getVersion();
$sql = <<<SQL
SELECT *
- Create a ticketCreate a ticket
Method bufferJob
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function bufferJob($queue_name, array $job)
{
$table_name = 'buffered_jobs';
$status_column = 'inserted';
if (isset($job['options']['run_after'])) {
- Create a ticketCreate a ticket
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = $this->database;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The class QueueManager has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. Open
class QueueManager
{
/**
* @param Config
*/
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Function getJobsToRunGenerator
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getJobsToRunGenerator()
{
$buffered_jobs = $this->sortBufferedJobs(
$this->filterFutureJobs($this->database->getAll('buffered_jobs'))
);
- Read upRead up
- Create a ticketCreate a ticket
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 __DIR__ . '/MigrationTemplate.php';
- Create a ticketCreate a ticket