jumper423/decaptcha

View on GitHub

Showing 73 of 73 total issues

Function decodeResponse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function decodeResponse($action, $data)
    {
        if (!array_key_exists($action, $this->decodeSettings[static::DECODE_ACTION])) {
            throw new DeCaptchaErrors('нет action');
        }
Severity: Minor
Found in src/services/RuCaptchaGeeTest.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 curlResponse has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function curlResponse($url, $data, $isPost = true, $isJson = false)
    {
        $curl = curl_init();
        if ($isJson) {
            $data = json_encode($data);
Severity: Minor
Found in src/core/DeCaptchaAbstract.php - About 1 hr to fix

    Method init has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function init()
        {
            parent::init();
    
            unset(
    Severity: Minor
    Found in src/services/RuCaptchaClick.php - About 1 hr to fix

      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

        Method requestRepeat has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            protected function requestRepeat($action, $decodeAction, $setParam, $decodeSerParam, $ok, $sleep, $repeat, $error = null)
        Severity: Major
        Found in src/core/DeCaptchaBase.php - About 1 hr to fix

          Function curlResponse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function curlResponse($url, $data, $isPost = true, $isJson = false)
              {
                  $curl = curl_init();
                  if ($isJson) {
                      $data = json_encode($data);
          Severity: Minor
          Found in src/core/DeCaptchaAbstract.php - About 55 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 variables with short names like $ok. Configured minimum length is 3.
          Open

              protected function requestRepeat($action, $decodeAction, $setParam, $decodeSerParam, $ok, $sleep, $repeat, $error = null)
          Severity: Minor
          Found in src/core/DeCaptchaBase.php by phpmd

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#shortvariable

          Avoid variables with short names like $tt. Configured minimum length is 3.
          Open

                  $tt = [];
          Severity: Minor
          Found in src/core/DeCaptchaWikiMain.php by phpmd

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#shortvariable

          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

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

                  $this->decodeSettings[static::DECODE_ACTION][static::DECODE_ACTION_RECOGNIZE] = [
                      static::DECODE_FORMAT => static::RESPONSE_TYPE_JSON,
                      static::DECODE_PARAMS => [
                          static::DECODE_PARAM_RESPONSE => [
                              static::DECODE_PARAM_SETTING_MARKER => 'errorId',
          Severity: Major
          Found in src/services/Anticaptcha.php and 2 other locations - About 45 mins to fix
          src/services/Anticaptcha.php on lines 172..185
          src/services/Anticaptcha.php on lines 186..199

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

          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

                  $this->decodeSettings[static::DECODE_ACTION][static::DECODE_ACTION_GET] = [
                      static::DECODE_FORMAT => static::RESPONSE_TYPE_JSON,
                      static::DECODE_PARAMS => [
                          static::DECODE_PARAM_RESPONSE => [
                              static::DECODE_PARAM_SETTING_MARKER => 'status',
          Severity: Major
          Found in src/services/Anticaptcha.php and 2 other locations - About 45 mins to fix
          src/services/Anticaptcha.php on lines 158..171
          src/services/Anticaptcha.php on lines 186..199

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

          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

                  $this->decodeSettings[static::DECODE_ACTION][static::DECODE_ACTION_BALANCE] = [
                      static::DECODE_FORMAT => static::RESPONSE_TYPE_JSON,
                      static::DECODE_PARAMS => [
                          static::DECODE_PARAM_RESPONSE => [
                              static::DECODE_PARAM_SETTING_MARKER => 'errorId',
          Severity: Major
          Found in src/services/Anticaptcha.php and 2 other locations - About 45 mins to fix
          src/services/Anticaptcha.php on lines 158..171
          src/services/Anticaptcha.php on lines 172..185

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

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

              public function getParamSpec($param, $spec = null, $coding = null)
              {
                  if (is_null($spec)) {
                      $spec = $param;
                  }
          Severity: Minor
          Found in src/core/DeCaptchaAbstract.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 requestRepeat has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function requestRepeat($action, $decodeAction, $setParam, $decodeSerParam, $ok, $sleep, $repeat, $error = null)
              {
                  if (is_null($error)) {
                      $error = static::DECODE_PARAM_RESPONSE;
                  }
          Severity: Minor
          Found in src/core/DeCaptchaBase.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 $result;
          Severity: Major
          Found in src/core/DeCaptchaWiki.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return (int) $this->params[$param];
            Severity: Major
            Found in src/core/DeCaptchaAbstract.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return null;
              Severity: Major
              Found in src/core/DeCaptchaAbstract.php - About 30 mins to fix

                The method curlResponse has a boolean flag argument $isJson, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    protected function curlResponse($url, $data, $isPost = true, $isJson = false)
                Severity: Minor
                Found in src/core/DeCaptchaAbstract.php by phpmd

                BooleanArgumentFlag

                Since: 1.4.0

                A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                Example

                class Foo {
                    public function bar($flag = true) {
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                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

                Avoid too many return statements within this method.
                Open

                                return (string) $this->params[$param];
                Severity: Major
                Found in src/core/DeCaptchaAbstract.php - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language