sensorario/resources

View on GitHub

Showing 7 of 7 total issues

Function check has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function check(Resource $resource)
    {
        foreach ($resource->mandatory() as $mandatoryProperty => $value) {
            if (isset($value['when']['condition'])) {
                $when = $value['when'];

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 ensureTypeIsValid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function ensureTypeIsValid()
    {
        if ($this->typeMismatch()) {
            if ($this->resource->isFieldNumericButString($this->fieldName)) {
                throw new \Sensorario\Resources\Exceptions\WrongPropertyValueException(
Severity: Minor
Found in src/Sensorario/Resources/Rulers/Ruler.php - About 45 mins to fix

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 properties has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    final public function properties()
    {
        $properties = $this->properties;

        foreach ($properties as $k => $v) {
Severity: Minor
Found in src/Sensorario/Resources/MagicResource.php - About 25 mins to fix

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 check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function check(Resource $resource)
    {
        foreach ($resource->properties() as $key => $value) {
            if (isset($resource->allowedValues()[$key])) {
                $allowedValues = $resource->allowedValues()[$key];
Severity: Minor
Found in src/Sensorario/Resources/Validators/Validators/AllowedValues.php - About 25 mins to fix

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 ensureValidConstraints has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function ensureValidConstraints($resources)
    {
        foreach ($resources['resources'] as $item) {
            if (isset($item['constraints'])) {
                foreach ($item['constraints'] as $name => $value) {
Severity: Minor
Found in src/Sensorario/Resources/Container.php - About 25 mins to fix

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 check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function check(Resource $resource)
    {
        foreach ($resource->properties() as $key => $value) {
            if (isset($resource->ranges()[$key])) {
                if ($value < $resource->ranges()[$key]['more_than']) {
Severity: Minor
Found in src/Sensorario/Resources/Validators/Validators/AllowedRanges.php - About 25 mins to fix

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 fillInRewrites has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function fillInRewrites(array $resources)
    {
        foreach ($resources as $item) {
            if (isset($item['rewrite'])) {
                foreach ($item['rewrite'] as $field => $rewriteRule) {
Severity: Minor
Found in src/Sensorario/Resources/Container.php - About 25 mins to fix

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

Severity
Category
Status
Source
Language