budde377/Part

View on GitHub
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php

Summary

Maintainability
F
3 days
Test Coverage

File GenericObjectTypeHandlerImpl.php has 426 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace ChristianBudde\Part\controller\ajax\type_handler;

use ChristianBudde\Part\controller\ajax\Server;
use ChristianBudde\Part\controller\json\JSONFunction;
Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 6 hrs to fix

GenericObjectTypeHandlerImpl has 33 functions (exceeds 20 allowed). Consider refactoring.
Open

class GenericObjectTypeHandlerImpl implements TypeHandler
{


    private $object;
Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 4 hrs to fix

Function parametersCheck has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    private function parametersCheck(array $functionArgs, array $parameters)
    {


        $numReqParam = 0;
Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 3 hrs 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 setUp has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function setUp(Server $server, $type)
    {

        if (in_array($type, $this->hasBeenSetUp)) {
            return;
Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 1 hr 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 handle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function handle($type, JSONFunction $function, $instance = null)
    {
        if (isset($this->alias[$type])) {
            foreach ($this->alias[$type] as $target) {
                if (!$this->canHandle($target, $function, $instance)) {
Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 1 hr 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 canHandle has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function canHandle($type, JSONFunction $function, $instance = null)
    {
        if (isset($this->alias[$type])) {
            $canHandle = false;
            foreach ($this->alias[$type] as $target) {
Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 1 hr 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

Method parametersCheck has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function parametersCheck(array $functionArgs, array $parameters)
    {


        $numReqParam = 0;
Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 1 hr to fix

Method setUp has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function setUp(Server $server, $type)
    {

        if (in_array($type, $this->hasBeenSetUp)) {
            return;
Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 1 hr to fix

Method handle has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function handle($type, JSONFunction $function, $instance = null)
    {
        if (isset($this->alias[$type])) {
            foreach ($this->alias[$type] as $target) {
                if (!$this->canHandle($target, $function, $instance)) {
Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 1 hr to fix

Function listFunctions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function listFunctions($type)
    {
        if (!$this->hasType($type)) {
            return array();
        }
Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 35 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 whitelistFunction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function whitelistFunction($type, $functionName)
    {

        if (isset($this->alias[$type])) {

Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 35 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 setUpReflectionClass has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function setUpReflectionClass($object)
    {
        if (is_string($object)) {
            $this->types[] = $object;
            $interface_exists = false;
Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 35 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

Avoid too many return statements within this method.
Open

            return;
Severity: Major
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return true;
Severity: Major
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return $result;
Severity: Major
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php - About 30 mins to fix

Function whitelistType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function whitelistType($type)
    {
        foreach (func_get_args() as $arg) {
            if (!in_array($arg, $this->types)) {
                continue;
Severity: Minor
Found in lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    private function callPreCallFunctions($type, $instance, $functionName, &$arguments)
    {

        $this->callArraysOfCallFunctions(function($function) use($type, $instance, $functionName, &$arguments) {
            $function($type, $instance, $functionName, $arguments);
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php on lines 500..510

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 128.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    private function callPostCallFunctions($type, $instance, $functionName, &$result)
    {
        $this->callArraysOfCallFunctions(function($function) use($type, $instance, $functionName, &$result) {
            $function($type, $instance, $functionName, $result);
        },
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php on lines 488..498

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 128.

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

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    public function addFunctionPostCallFunction($type, $name, callable $function)
    {

        $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $name, $function){
            $this->fnPostCallFunctions[$type][$name][] = $function;
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php on lines 87..96
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php on lines 194..203

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 92.

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

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    public function addFunctionAuthFunction($type, $functionName, callable $function)
    {

        $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $functionName, $function){
            $this->fnAuthFunctions[$type][$functionName][] = $function;
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php on lines 194..203
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php on lines 212..221

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 92.

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

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    public function addFunctionPreCallFunction($type, $name, callable $function)
    {
        $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $name, $function){
            $this->fnPreCallFunctions[$type][$name][] = $function;
        }, function($target) use ( $function, $name){
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php on lines 87..96
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php on lines 212..221

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 92.

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

Further Reading

There are no issues that match your filters.

Category
Status