Showing 529 of 529 total issues
Function process
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public function process(
PropertyInterface $property,
mixed $filterList,
GeneratorConfiguration $generatorConfiguration,
Schema $schema,
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function addLengthValidator(PropertyInterface $property, JsonSchema $propertySchema): void
{
$json = $propertySchema->getJson();
if (isset($json[static::JSON_FIELD_MIN_LENGTH])) {
- 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 168.
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
private function addLengthValidation(PropertyInterface $property, JsonSchema $propertySchema): void
{
$json = $propertySchema->getJson();
if (isset($json[self::JSON_FIELD_MIN_ITEMS])) {
- 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 168.
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
Function transferPatternPropertiesFilterToProperty
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
protected function transferPatternPropertiesFilterToProperty(
Schema $schema,
GeneratorConfiguration $generatorConfiguration,
): void {
$patternPropertiesValidators = array_filter(
- 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
GeneratorConfiguration
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class GeneratorConfiguration
{
/** @var string */
protected $namespacePrefix = '';
/** @var bool */
Method process
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(
PropertyInterface $property,
mixed $filterList,
GeneratorConfiguration $generatorConfiguration,
Schema $schema,
PropertyProxy
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class PropertyProxy extends AbstractProperty
{
/**
* PropertyProxy constructor.
*
Schema
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class Schema
{
use JsonSchemaTrait;
/** @var string */
Property
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class Property extends AbstractProperty
{
/** @var PropertyType|null */
protected $outputType;
/** @var bool */
Method process
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void
{
$generatorConfiguration->addFilter(new EnumFilter());
foreach ($schema->getProperties() as $property) {
Method transferPatternPropertiesFilterToProperty
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function transferPatternPropertiesFilterToProperty(
Schema $schema,
GeneratorConfiguration $generatorConfiguration,
): void {
$patternPropertiesValidators = array_filter(
Function addSerializeFunctionsForTransformingFilters
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function addSerializeFunctionsForTransformingFilters(
Schema $schema,
GeneratorConfiguration $generatorConfiguration,
): void {
foreach ($schema->getProperties() as $property) {
- 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 addSerializeFunctionsForTransformingFilters
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function addSerializeFunctionsForTransformingFilters(
Schema $schema,
GeneratorConfiguration $generatorConfiguration,
): void {
foreach ($schema->getProperties() as $property) {
Method generateValidators
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function generateValidators(PropertyInterface $property, JsonSchema $propertySchema): void
{
$json = $propertySchema->getJson()['propertySchema']->getJson();
if (!isset($json['then']) && !isset($json['else'])) {
Method generateValidators
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function generateValidators(PropertyInterface $property, JsonSchema $propertySchema): void
{
$json = $propertySchema->getJson()['propertySchema']->getJson();
if (empty($json[$propertySchema->getJson()['type']]) &&
Method createMergedProperty
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createMergedProperty(
Schema $schema,
PropertyInterface $property,
array $compositionProperties,
JsonSchema $propertySchema,
Method getCheck
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getCheck(): string
{
/**
* Add a method to the schema to gather values from a nested object which are modified.
* This is required to adopt filter changes to the values which are passed into a merged property
Function generateValidatorPropertyMap
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function generateValidatorPropertyMap(Schema $schema): array
{
$validatorPropertyMap = [];
// get all base validators which are composed value validators and set up a map of affected object properties
- 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 process
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void
{
$generatorConfiguration->addFilter(new EnumFilter());
foreach ($schema->getProperties() as $property) {
- 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 excessively long class names like ExtendObjectPropertiesMatchingPatternPropertiesPostProcessor. Keep class name length under 40. Open
class ExtendObjectPropertiesMatchingPatternPropertiesPostProcessor extends PostProcessor
{
/**
* @throws SchemaException
*/
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}