jkphl/antibot

View on GitHub

Showing 8 of 16 total issues

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

    public function validateRequest(
        ServerRequestInterface $request,
        ValidationResultInterface $result
    ): ValidationResultInterface {
        $this->logger->info('Start validation');
Severity: Minor
Found in src/Antibot/Domain/Antibot.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 validateRequestTiming has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function validateRequestTiming(string $hmac, Antibot $antibot, array $hmacParams): bool
    {
        // If submission time checks are enabled
        if (!empty($this->submissionTimes)) {
            list($first, $min, $max) = $this->submissionTimes;
Severity: Minor
Found in src/Antibot/Ports/Validators/HmacValidator.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 testRequestTimingValidation has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testRequestTimingValidation(): void
    {
        $session       = md5(rand());
        $antibot       = $this->createAntibot($session);
        $hmacValidator = new HmacValidator();
Severity: Minor
Found in src/Antibot/Tests/Ports/HmacValidatorTest.php - About 1 hr to fix

    Function validateHoneypotsRecursive has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function validateHoneypotsRecursive(array $honeypots, array $data, Antibot $antibot, $prefix = null): bool
        {
            // Run through the honeypot configuration
            foreach ($honeypots as $name => $config) {
                if (is_array($config)) {
    Severity: Minor
    Found in src/Antibot/Ports/Validators/HoneypotValidator.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 testHoneypots has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function testHoneypots(): void
        {
            $renderer          = function (InputElement $input, string $html) {
                return '<label style="display:none">' . $html . '</label>';
            };
    Severity: Minor
    Found in src/Antibot/Tests/Ports/HoneypotValidatorTest.php - About 1 hr to fix

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

          protected function validateRequestTiming(string $hmac, Antibot $antibot, array $hmacParams): bool
          {
              // If submission time checks are enabled
              if (!empty($this->submissionTimes)) {
                  list($first, $min, $max) = $this->submissionTimes;
      Severity: Minor
      Found in src/Antibot/Ports/Validators/HmacValidator.php - About 1 hr to fix

        Method probeTimedHmac has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                string $hmac,
                Antibot $antibot,
                array $hmacParams,
                int $timestamp,
                bool $followUp = false
        Severity: Minor
        Found in src/Antibot/Ports/Validators/HmacValidator.php - About 35 mins to fix

          Method probeTimedHmacAsInitialAndFollowup has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  string $hmac,
                  Antibot $antibot,
                  array $hmacParams,
                  int $timestamp,
                  int $initial
          Severity: Minor
          Found in src/Antibot/Ports/Validators/HmacValidator.php - About 35 mins to fix
            Severity
            Category
            Status
            Source
            Language