Showing 579 of 579 total issues
FieldDescriptor
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
final class FieldDescriptor
{
/**
* Regular expression pattern for matching a valid field name. The pattern allows
* for camelCase fields name but snake_case is recommend.
The class FieldDescriptorTest has 24 public methods. Consider refactoring FieldDescriptorTest to keep number of public methods under 10. Open
class FieldDescriptorTest extends \PHPUnit_Framework_TestCase
{
/** FieldDescriptor */
protected $field;
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class XmlUtils has an overall complexity of 52 which is very high. The configured complexity threshold is 50. Open
class XmlUtils
{
/**
* This class should not be instantiated.
*/
- Exclude checks
The class FieldDescriptor has an overall complexity of 73 which is very high. The configured complexity threshold is 50. Open
final class FieldDescriptor
{
/**
* Regular expression pattern for matching a valid field name. The pattern allows
* for camelCase fields name but snake_case is recommend.
- Exclude checks
The class Generator has 12 public methods. Consider refactoring Generator to keep number of public methods under 10. Open
abstract class Generator
{
const TEMPLATE_DIR = __DIR__ . '/Twig/';
const LANGUAGE = 'unknown';
const EXTENSION = '.unk';
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class Generator has an overall complexity of 50 which is very high. The configured complexity threshold is 50. Open
abstract class Generator
{
const TEMPLATE_DIR = __DIR__ . '/Twig/';
const LANGUAGE = 'unknown';
const EXTENSION = '.unk';
- Exclude checks
The class SchemaParser has an overall complexity of 63 which is very high. The configured complexity threshold is 50. Open
class SchemaParser
{
/** @var array */
protected $files = [];
- Exclude checks
Method generateManifest
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateManifest(array $schemas)
{
$response = new GeneratorResponse();
$manifests = ['all' => []];
Function validate
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function validate(SchemaDescriptor $a, SchemaDescriptor $b)
{
$fa = array_merge($a->getInheritedFields(), $a->getFields());
$fb = array_merge($b->getInheritedFields(), $b->getFields());
- 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 __construct
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($name, array $parameters)
{
if (!$name || strlen($name) > 127 || preg_match(self::VALID_NAME_PATTERN, $name) === false) {
throw new \InvalidArgumentException(
sprintf(
- 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
FieldDescriptorTest
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class FieldDescriptorTest extends \PHPUnit_Framework_TestCase
{
/** FieldDescriptor */
protected $field;
Generator
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class Generator
{
const TEMPLATE_DIR = __DIR__ . '/Twig/';
const LANGUAGE = 'unknown';
const EXTENSION = '.unk';
Method __construct
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct()
{
$enums = [];
$schemas = [];
Function run
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function run($language, CompileOptions $options)
{
$namespaces = $options->getNamespaces();
if (!$namespaces || count($namespaces) === 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 loadFile
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public static function loadFile($file, $schemaOrCallable = null)
{
$content = @file_get_contents($file);
if ('' === trim($content)) {
throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));
- 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 __construct
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($name, array $parameters)
{
if (!$name || strlen($name) > 127 || preg_match(self::VALID_NAME_PATTERN, $name) === false) {
throw new \InvalidArgumentException(
sprintf(
Function validate
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function validate(SchemaDescriptor $a, SchemaDescriptor $b)
{
$fa = array_merge($a->getInheritedFields(), $a->getFields());
$fb = array_merge($b->getInheritedFields(), $b->getFields());
- 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
File FieldDescriptor.php
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Gdbots\Pbjc;
use Gdbots\Common\Util\NumberUtils;
Method parse
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function parse(array $data)
{
$schemaId = SchemaId::fromString($data['id']);
$parameters = [
Function fromFile
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function fromFile($file)
{
if (!array_key_exists($file, $this->files)) {
$xmlData = $this->getXmlData($file);
- 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"