Showing 289 of 291 total issues

Function ip_address has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

    public static function ip_address($proxy_ips = [])
    {
        if (self::$ip_address) {
            return self::$ip_address;
        }
Severity: Minor
Found in core/LibRequest.php - About 1 day 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

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

    public function group($shared, $list)
    {
        $middleware = null;
        $sharedPath = '';
        $sharedNamespace = '';
Severity: Major
Found in mvc/Adah.php and 1 other location - About 7 hrs to fix
mvc/Zillah.php on lines 224..251

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

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

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

    public function group($shared, $list)
    {
        $middleware = null;
        $sharedPath = '';
        $sharedNamespace = '';
Severity: Major
Found in mvc/Zillah.php and 1 other location - About 7 hrs to fix
mvc/Adah.php on lines 169..196

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

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

Function seekRouteByTreeForKeychain has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    protected function seekRouteByTreeForKeychain($tree, $keychain, $method, &$params = [])
    {
        if ($this->debug) {
            echo __METHOD__ .
                ' tree nodes: ' . json_encode(array_keys($tree)) .
Severity: Minor
Found in mvc/Zillah.php - About 5 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

Method buildHTML has 124 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function buildHTML($content, $components)
    {
        $autoURLBase = $this->getURLRootString();
        $title = $this->wikiTitle;
        $navigator = "";
Severity: Major
Found in wiki/MarkdownBaruch.php - About 4 hrs to fix

    Function executeCurl has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function executeCurl($method, $url, $data = null, $headers = [], $cookies = [], $bodyAsJson = false, $logger = null)
        {
            //$logger = $this->getFileLogger();
            $ch = curl_init();
    
    
    Severity: Minor
    Found in helper/CommonHelper.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

    File LibPDO.php has 314 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Created by PhpStorm.
     * User: Sinri
     * Date: 2017/7/14
    Severity: Minor
    Found in core/LibPDO.php - About 3 hrs to fix

      File LibRequest.php has 310 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * Created by PhpStorm.
       * User: Sinri
       * Date: 2017/5/9
      Severity: Minor
      Found in core/LibRequest.php - About 3 hrs to fix

        Function loadController has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public function loadController($basePath, $controllerClass, $middleware = null)
            {
                $method_list = get_class_methods($controllerClass);
                $reflector = new \ReflectionClass($controllerClass);
                foreach ($method_list as $method) {
        Severity: Minor
        Found in mvc/Adah.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

        LibPDO has 28 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class LibPDO
        {
            /**
             * @var \PDO
             */
        Severity: Minor
        Found in core/LibPDO.php - About 3 hrs to fix

          The class Adah has an overall complexity of 60 which is very high. The configured complexity threshold is 50.
          Open

          class Adah extends RouterInterface
          {
              const ROUTE_PARAM_METHOD = "METHOD";
              const ROUTE_PARAM_PATH = "PATH";
              const ROUTE_PARAM_CALLBACK = "CALLBACK";
          Severity: Minor
          Found in mvc/Adah.php by phpmd

          LibRequest has 28 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class LibRequest
          {
              const METHOD_ANY = "ANY";//since v2.1.3 for TreeRouter
          
              const METHOD_HEAD = "HEAD";//since v1.3.0
          Severity: Minor
          Found in core/LibRequest.php - About 3 hrs to fix

            The class Zillah has an overall complexity of 77 which is very high. The configured complexity threshold is 50.
            Open

            class Zillah extends RouterInterface
            {
                const ROUTE_PARAM_METHOD = "METHOD";
                const ROUTE_PARAM_PATH = "PATH";
                const ROUTE_PARAM_CALLBACK = "CALLBACK";
            Severity: Minor
            Found in mvc/Zillah.php by phpmd

            The class LibPDO has an overall complexity of 69 which is very high. The configured complexity threshold is 50.
            Open

            class LibPDO
            {
                /**
                 * @var \PDO
                 */
            Severity: Minor
            Found in core/LibPDO.php by phpmd

            The class Lamech has an overall complexity of 57 which is very high. The configured complexity threshold is 50.
            Open

            class Lamech
            {
                protected $gateway = "index.php";
                protected $session_dir;
                protected $router;
            Severity: Minor
            Found in mvc/Lamech.php by phpmd

            The class LibRequest has an overall complexity of 78 which is very high. The configured complexity threshold is 50.
            Open

            class LibRequest
            {
                const METHOD_ANY = "ANY";//since v2.1.3 for TreeRouter
            
                const METHOD_HEAD = "HEAD";//since v1.3.0
            Severity: Minor
            Found in core/LibRequest.php by phpmd

            The class CommonHelper has an overall complexity of 53 which is very high. The configured complexity threshold is 50.
            Open

            class CommonHelper
            {
                /**
                 * 按照PSR-0规范,不过PSR-4看起来也是支持的
                 * @since 2.0.0 turn to static
            Severity: Minor
            Found in helper/CommonHelper.php by phpmd

            Function loadAllControllersInDirectoryAsCI has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

                public function loadAllControllersInDirectoryAsCI($directory, $urlBase = '', $controllerNamespaceBase = '', $middleware = '')
                {
                    if (!file_exists($directory) || !is_dir($directory)) {
                        if ($this->debug) {
                            echo __METHOD__ . " warning: this is not a direcoty: " . $directory . PHP_EOL;
            Severity: Minor
            Found in mvc/Adah.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

            Method seekRouteByTreeForKeychain has 80 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function seekRouteByTreeForKeychain($tree, $keychain, $method, &$params = [])
                {
                    if ($this->debug) {
                        echo __METHOD__ .
                            ' tree nodes: ' . json_encode(array_keys($tree)) .
            Severity: Major
            Found in mvc/Zillah.php - About 3 hrs to fix

              Function buildCondition has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected final function buildCondition($conditions, $glue = 'AND')
                  {
                      $condition_sql = "";
                      if (is_string($conditions)) {
                          $condition_sql = $conditions;
              Severity: Minor
              Found in core/AbstractDataModel.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

              Severity
              Category
              Status
              Source
              Language