dadajuice/zephyrus

View on GitHub

Showing 84 of 84 total issues

Consider simplifying this complex logical expression.
Open

        if (empty($uuid) || empty($chunk) || empty($totalChunks) || empty($totalFileSize)
            || !is_numeric($chunk) || !is_numeric($totalChunks) || !is_numeric($totalFileSize)) {
            throw HttpUploadException::invalidChunk();
        }
Severity: Major
Found in src/Zephyrus/Utilities/HttpUploadReceiver.php - About 1 hr to fix

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

        public static function isDateTime12Hours($data, bool $includeSeconds = false): bool
        {
            if (empty($data) || strpos($data, ' ') === false) {
                return false;
            }
    Severity: Minor
    Found in src/Zephyrus/Utilities/Validations/TimeValidations.php and 1 other location - About 55 mins to fix
    src/Zephyrus/Utilities/Validations/TimeValidations.php on lines 46..53

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

    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

        public static function isDateTime24Hours($data, bool $includeSeconds = false): bool
        {
            if (empty($data) || strpos($data, ' ') === false) {
                return false;
            }
    Severity: Minor
    Found in src/Zephyrus/Utilities/Validations/TimeValidations.php and 1 other location - About 55 mins to fix
    src/Zephyrus/Utilities/Validations/TimeValidations.php on lines 37..44

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

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

        private function detectIntrusion(stdClass $rule, $parameter, $data, IntrusionReport $report)
        {
            if (is_array($data)) {
                foreach ($data as $key => $value) {
                    $this->detectIntrusion($rule, $parameter . '.' . $key, $value, $report);
    Severity: Minor
    Found in src/Zephyrus/Security/IntrusionDetection/IntrusionMonitor.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

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

        public function zip(string $zipPath, ?string $password = null, int $encryptionMethod = ZipArchive::EM_AES_256): ZipArchive
        {
            $zip = new ZipArchive();
            if ($zip->open($zipPath, ZipArchive::CREATE) === true) {
                foreach ($this->getFiles() as $file) {
    Severity: Minor
    Found in src/Zephyrus/Utilities/FileSystem/Directory.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

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

        private function copyRecursively(string $source, string $destination)
        {
            $dir = opendir($source);
            @mkdir($destination);
            while (false !== ($file = readdir($dir))) {
    Severity: Minor
    Found in src/Zephyrus/Utilities/FileSystem/Directory.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

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

        public function run(): void
        {
            $failedRules = [];
            $successRules = [];
            $isStrict = $this->request->getRouteDefinition()->isStrictRuleInterpretation();
    Severity: Minor
    Found in src/Zephyrus/Security/AuthorizationGuard.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 2 locations. Consider refactoring.
    Open

        public static function decryptFile(string $cipherTextFilename, string $key, ?string $destination = null): void
        {
            if (!file_exists($cipherTextFilename)) {
                throw new InvalidArgumentException("Specified file to decrypt does not exist");
            }
    Severity: Minor
    Found in src/Zephyrus/Security/Cryptography.php and 1 other location - About 45 mins to fix
    src/Zephyrus/Security/Cryptography.php on lines 262..270

    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 2 locations. Consider refactoring.
    Open

        public static function encryptFile(string $plainTextFilename, string $key, ?string $destination = null): void
        {
            if (!file_exists($plainTextFilename)) {
                throw new InvalidArgumentException("Specified file to encrypt does not exist");
            }
    Severity: Minor
    Found in src/Zephyrus/Security/Cryptography.php and 1 other location - About 45 mins to fix
    src/Zephyrus/Security/Cryptography.php on lines 282..290

    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

    Consider simplifying this complex logical expression.
    Open

            if ($this->isGetSecured() && $method == "GET") {
                return true;
            } elseif ($this->isPostSecured() && $method == "POST") {
                return true;
            } elseif ($this->isPutSecured() && $method == "PUT") {
    Severity: Major
    Found in src/Zephyrus/Security/CsrfGuard.php - About 40 mins to fix

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

          public function get(string $url, callable|array $callback, array $acceptedFormats = [ContentType::ANY], array $authorizationRules = []): void
          {
              $route = new RouteDefinition($url);
              $route->setCallback($callback);
              $route->setAcceptedContentTypes($acceptedFormats);
      Severity: Major
      Found in src/Zephyrus/Network/Router/RouteRepository.php and 4 other locations - About 40 mins to fix
      src/Zephyrus/Network/Router/RouteRepository.php on lines 156..163
      src/Zephyrus/Network/Router/RouteRepository.php on lines 176..183
      src/Zephyrus/Network/Router/RouteRepository.php on lines 197..204
      src/Zephyrus/Network/Router/RouteRepository.php on lines 218..225

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

      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 5 locations. Consider refactoring.
      Open

          public function put(string $url, callable|array $callback, array $acceptedFormats = [ContentType::ANY], array $authorizationRules = []): void
          {
              $route = new RouteDefinition($url);
              $route->setCallback($callback);
              $route->setAcceptedContentTypes($acceptedFormats);
      Severity: Major
      Found in src/Zephyrus/Network/Router/RouteRepository.php and 4 other locations - About 40 mins to fix
      src/Zephyrus/Network/Router/RouteRepository.php on lines 136..143
      src/Zephyrus/Network/Router/RouteRepository.php on lines 156..163
      src/Zephyrus/Network/Router/RouteRepository.php on lines 197..204
      src/Zephyrus/Network/Router/RouteRepository.php on lines 218..225

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

      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 5 locations. Consider refactoring.
      Open

          public function delete(string $url, callable|array $callback, array $acceptedFormats = [ContentType::ANY], array $authorizationRules = []): void
          {
              $route = new RouteDefinition($url);
              $route->setCallback($callback);
              $route->setAcceptedContentTypes($acceptedFormats);
      Severity: Major
      Found in src/Zephyrus/Network/Router/RouteRepository.php and 4 other locations - About 40 mins to fix
      src/Zephyrus/Network/Router/RouteRepository.php on lines 136..143
      src/Zephyrus/Network/Router/RouteRepository.php on lines 156..163
      src/Zephyrus/Network/Router/RouteRepository.php on lines 176..183
      src/Zephyrus/Network/Router/RouteRepository.php on lines 197..204

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

      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 5 locations. Consider refactoring.
      Open

          public function post(string $url, callable|array $callback, array $acceptedFormats = [ContentType::ANY], array $authorizationRules = []): void
          {
              $route = new RouteDefinition($url);
              $route->setCallback($callback);
              $route->setAcceptedContentTypes($acceptedFormats);
      Severity: Major
      Found in src/Zephyrus/Network/Router/RouteRepository.php and 4 other locations - About 40 mins to fix
      src/Zephyrus/Network/Router/RouteRepository.php on lines 136..143
      src/Zephyrus/Network/Router/RouteRepository.php on lines 176..183
      src/Zephyrus/Network/Router/RouteRepository.php on lines 197..204
      src/Zephyrus/Network/Router/RouteRepository.php on lines 218..225

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

      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 5 locations. Consider refactoring.
      Open

          public function patch(string $url, callable|array $callback, array $acceptedFormats = [ContentType::ANY], array $authorizationRules = []): void
          {
              $route = new RouteDefinition($url);
              $route->setCallback($callback);
              $route->setAcceptedContentTypes($acceptedFormats);
      Severity: Major
      Found in src/Zephyrus/Network/Router/RouteRepository.php and 4 other locations - About 40 mins to fix
      src/Zephyrus/Network/Router/RouteRepository.php on lines 136..143
      src/Zephyrus/Network/Router/RouteRepository.php on lines 156..163
      src/Zephyrus/Network/Router/RouteRepository.php on lines 176..183
      src/Zephyrus/Network/Router/RouteRepository.php on lines 218..225

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

      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

          public static function isIPv6($data, bool $includeReserved = true, bool $includePrivate = true): bool
          {
              $flag = FILTER_FLAG_IPV6
                  | ((!$includeReserved) ? FILTER_FLAG_NO_RES_RANGE : 0)
                  | ((!$includePrivate) ? FILTER_FLAG_NO_PRIV_RANGE : 0);
      Severity: Minor
      Found in src/Zephyrus/Utilities/Validations/SpecializedValidations.php and 1 other location - About 35 mins to fix
      src/Zephyrus/Utilities/Validations/SpecializedValidations.php on lines 78..84

      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 2 locations. Consider refactoring.
      Open

          public static function isIPv4($data, bool $includeReserved = true, bool $includePrivate = true): bool
          {
              $flag = FILTER_FLAG_IPV4
                  | ((!$includeReserved) ? FILTER_FLAG_NO_RES_RANGE : 0)
                  | ((!$includePrivate) ? FILTER_FLAG_NO_PRIV_RANGE : 0);
      Severity: Minor
      Found in src/Zephyrus/Utilities/Validations/SpecializedValidations.php and 1 other location - About 35 mins to fix
      src/Zephyrus/Utilities/Validations/SpecializedValidations.php on lines 86..92

      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

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

          private function buildHeaderLine(string $name, array $sources): string
          {
              $header = '';
              if (!empty($sources)) {
                  $value = "";
      Severity: Minor
      Found in src/Zephyrus/Security/ContentSecurityPolicy.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 injectForms has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function injectForms(string $html): string
          {
              preg_match_all("/<form(.*?)>(.*?)<\\/form>/is", $html, $matches, PREG_SET_ORDER);
              if (is_array($matches)) {
                  foreach ($matches as $match) {
      Severity: Minor
      Found in src/Zephyrus/Security/CsrfGuard.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 buildCurlFile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function buildCurlFile(?string $uploadFilename = null): CURLFile
          {
              if (is_null($uploadFilename)) {
                  $uploadFilename = $this->getBasename();
              } else {
      Severity: Minor
      Found in src/Zephyrus/Utilities/FileSystem/File.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

      Severity
      Category
      Status
      Source
      Language