idealo/php-rdkafka-ffi

View on GitHub
resources/ffigen/LibrdkafkaHeaderFiles.php

Summary

Maintainability
B
6 hrs
Test Coverage

Method prepareFileContent has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function prepareFileContent(string $file, string $content, string $version): string
    {
        if (strpos($file, 'rdkafka.h') !== false) {
            // prefilter header file content - not supported by cparser
            $content = preg_replace_callback(
Severity: Major
Found in resources/ffigen/LibrdkafkaHeaderFiles.php - About 2 hrs to fix

    Method loadSupportedVersions has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function loadSupportedVersions(): array
        {
            echo 'Load librdkafka releases ...';
    
            $content = file_get_contents(
    Severity: Minor
    Found in resources/ffigen/LibrdkafkaHeaderFiles.php - About 1 hr to fix

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

          public function prepareVersion(string $version): void
          {
              if (array_key_exists($version, $this->supportedVersions) === false) {
                  throw new \InvalidArgumentException(sprintf('Version %s not supported', $version));
              }
      Severity: Minor
      Found in resources/ffigen/LibrdkafkaHeaderFiles.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

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

          private function loadSupportedVersions(): array
          {
              echo 'Load librdkafka releases ...';
      
              $content = file_get_contents(
      Severity: Minor
      Found in resources/ffigen/LibrdkafkaHeaderFiles.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 $content;
      Severity: Major
      Found in resources/ffigen/LibrdkafkaHeaderFiles.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                            return '';
        Severity: Major
        Found in resources/ffigen/LibrdkafkaHeaderFiles.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                              return '//' . $matches[1];
          Severity: Major
          Found in resources/ffigen/LibrdkafkaHeaderFiles.php - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status