jumper423/decaptcha

View on GitHub
src/core/DeCaptchaWiki.php

Summary

Maintainability
F
4 days
Test Coverage

Method __construct has 457 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __construct($class)
    {
        $this->class = $class;
        $this->texts = [
            'constructor_data' => [
Severity: Major
Found in src/core/DeCaptchaWiki.php - About 2 days to fix

    File DeCaptchaWiki.php has 724 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace jumper423\decaptcha\core;
    
    /**
    Severity: Major
    Found in src/core/DeCaptchaWiki.php - About 1 day to fix

      Method viewExamples has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function viewExamples()
          {
              $class = $this->class;
              $reflection = (new \ReflectionClass($class));
      
      
      Severity: Major
      Found in src/core/DeCaptchaWiki.php - About 2 hrs to fix

        Function viewFields has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function viewFields()
            {
                $class = $this->class;
                $str = " {$this->getText(['table', 'th', 'name'])} | {$this->getText(['table', 'th', 'code'])} | {$this->getText(['table', 'th', 'type'])} | {$this->getText(['table', 'th', 'req'])} | {$this->getText(['table', 'th', 'def'])} | {$this->getText(['table', 'th', 'enum'])} | {$this->getText(['table', 'th', 'desc'])} ".PHP_EOL;
                $str .= ' --- | --- | --- | --- | --- | --- | --- '.PHP_EOL;
        Severity: Minor
        Found in src/core/DeCaptchaWiki.php - About 2 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 view has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function view()
            {
                $str = $this->getText(['service', 'name']).PHP_EOL;
                $str .= '=============='.PHP_EOL;
                $str .= "{$this->getText(['slug', 'menu'])}".PHP_EOL;
        Severity: Minor
        Found in src/core/DeCaptchaWiki.php - About 1 hr to fix

          Function getText has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getText($name, $separator = '; ')
              {
                  $getResult = function ($name, $texts) {
                      if (is_array($name)) {
                          $name = implode('_', $name);
          Severity: Minor
          Found in src/core/DeCaptchaWiki.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

          Avoid too many return statements within this method.
          Open

                  return $result;
          Severity: Major
          Found in src/core/DeCaptchaWiki.php - About 30 mins to fix

            Missing class import via use statement (line '624', column '28').
            Open

                    $reflection = (new \ReflectionClass($class));
            Severity: Minor
            Found in src/core/DeCaptchaWiki.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '550', column '28').
            Open

                    $reflection = (new \ReflectionClass($class));
            Severity: Minor
            Found in src/core/DeCaptchaWiki.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '769', column '21').
            Open

                    return (new \ReflectionClass($class))->getShortName().'-'.$lang.'.md';
            Severity: Minor
            Found in src/core/DeCaptchaWiki.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '720', column '27').
            Open

                    $constants = (new \ReflectionClass($class))->getConstants();
            Severity: Minor
            Found in src/core/DeCaptchaWiki.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            There are no issues that match your filters.

            Category
            Status