Showing 89 of 92 total issues
Function processObject
has a Cognitive Complexity of 271 (exceeds 5 allowed). Consider refactoring. Open
private function processObject($data, Context $options, $path, $result = null)
{
$import = $options->import;
$hasMapping = $this->properties !== null && isset($this->properties->__dataToProperty[$options->mapping]);
- 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
<?php
use Swaggest\JsonSchema\Context;
use Swaggest\JsonSchema\InvalidValue;
- 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 789.
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
<?php
use Swaggest\JsonSchema\Context;
use Swaggest\JsonSchema\InvalidValue;
- 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 789.
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 unicodeValidationError
has 625 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function unicodeValidationError($data, &$sanitized = null)
{
static $excluded = array(
"\xD9\x80" => '\u0640',
"\xDF\xBA" => '\u07FA',
File Schema.php
has 1068 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Swaggest\JsonSchema;
File Iri.php
has 664 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Swaggest\JsonSchema\Constraint\Format;
class Iri
Method processObject
has 293 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processObject($data, Context $options, $path, $result = null)
{
$import = $options->import;
$hasMapping = $this->properties !== null && isset($this->properties->__dataToProperty[$options->mapping]);
Function process
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
public function process($data, Context $options, $path = '#', $result = null)
{
$origData = $data;
$import = $options->import;
- 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 resolveReference
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
public function resolveReference($referencePath)
{
if ($this->resolutionScope) {
$referencePath = Helper::resolveURI($this->resolutionScope, $referencePath);
}
- 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 provider
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
private static function provider($path)
{
$testCases = array();
if ($handle = opendir($path)) {
- 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 provider
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
private static function provider($path)
{
$testCases = array();
if ($handle = opendir($path)) {
- 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 validationError
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
public static function validationError($data, $options = 0)
{
if ($options === Uri::IS_URI_TEMPLATE) {
$opened = false;
for ($i = 0; $i < strlen($data); ++$i) {
- 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
Schema
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
class Schema extends JsonSchema implements MetaHolder, SchemaContract, HasDefault
{
const ENUM_NAMES_PROPERTY = 'x-enum-names';
const CONST_PROPERTY = 'const';
const DEFAULT_PROPERTY = 'default';
Function processArray
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
private function processArray($data, Context $options, $path, $result)
{
$count = count($data);
if (!$options->skipValidation) {
if ($this->minItems !== null && $count < $this->minItems) {
- 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 32 (exceeds 5 allowed). Consider refactoring. Open
public static function process(Context $options, $encoding, $mediaType, $data, $import = true)
{
if ($import) {
if ($encoding !== null) {
switch ($encoding) {
- 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 processNumeric
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
private function processNumeric($data, $path)
{
if ($this->multipleOf !== null) {
$div = $data / $this->multipleOf;
if ($div != (int)$div && ($div = $data * (1 / $this->multipleOf)) && ($div != (int)$div)) {
- 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 process
has 107 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process($data, Context $options, $path = '#', $result = null)
{
$origData = $data;
$import = $options->import;
Function jsonSerialize
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
$result = new \stdClass();
$schema = static::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
Method processArray
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processArray($data, Context $options, $path, $result)
{
$count = count($data);
if (!$options->skipValidation) {
if ($this->minItems !== null && $count < $this->minItems) {
Function getSchemaPointers
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public static function getSchemaPointers($path, $isURIFragmentId = false)
{
$items = explode('->', $path);
unset($items[0]);
$result = array();
- 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"