efureev/dev-tools

View on GitHub

Showing 13 of 13 total issues

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

    public function assertArrayStructure(array $structure, $testing_array): void
    {
        foreach ($structure as $key => $value) {
            if (\is_array($value)) {
                if ($key === '*') {
Severity: Minor
Found in src/Tests/PHPUnit/Traits/AdditionalAssertionsTrait.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 fixLaravelLogFileName has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function fixLaravelLogFileName(string $default_log_file_name): string
    {
        // For Laravel 5.7 and higher
        if (\class_exists(LogManager::class)) {
            /** @var LogManager $logger */
Severity: Minor
Found in src/Tests/PHPUnit/Traits/LaravelLogFilesAssertsTrait.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 assertClassUsesTraits has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function assertClassUsesTraits($class, $expected_traits, string $message = ''): void
    {
        /**
         * Returns all traits used by a trait and its traits.
         *
Severity: Minor
Found in src/Tests/PHPUnit/Traits/AdditionalAssertionsTrait.php - About 1 hr to fix

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

        protected function setUpTraits(): array
        {
            $uses = parent::setUpTraits();
    
            if (
    Severity: Minor
    Found in src/Tests/PHPUnit/AbstractLaravelTestCase.php - About 1 hr to fix

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

          public function createApplication(): Application
          {
              foreach ((array)$this->getApplicationBootstrapFiles() as $path) {
                  if (\file_exists($path)) {
                      /** @var Application $app */
      Severity: Minor
      Found in src/Tests/PHPUnit/Traits/CreatesApplicationTrait.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

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

          public function assertEventHasNoListener($event_abstract, $listener_class, string $message = ''): void
          {
              if (\is_object($listener_class)) {
                  $listener_class = \get_class($listener_class);
              }
      Severity: Minor
      Found in src/Tests/PHPUnit/Traits/LaravelEventsAssertionsTrait.php and 1 other location - About 45 mins to fix
      src/Tests/PHPUnit/Traits/LaravelEventsAssertionsTrait.php on lines 65..78

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

      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 function assertEventHasListener($event_abstract, $listener_class, string $message = ''): void
          {
              if (\is_object($listener_class)) {
                  $listener_class = \get_class($listener_class);
              }
      Severity: Minor
      Found in src/Tests/PHPUnit/Traits/LaravelEventsAssertionsTrait.php and 1 other location - About 45 mins to fix
      src/Tests/PHPUnit/Traits/LaravelEventsAssertionsTrait.php on lines 96..109

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

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

          public function clearLaravelLogs($logs_directory_path = null): void
          {
              $fs = new Filesystem;
              $directory_path = $logs_directory_path ?? $this->getDefaultLogsDirectoryPath();
      
      
      Severity: Minor
      Found in src/Tests/PHPUnit/Traits/LaravelLogFilesAssertsTrait.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 assertArtisanCommandExists has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function assertArtisanCommandExists($command, string $message = ''): void
          {
              if (\is_object($command)) {
                  $command = \get_class($command);
              }
      Severity: Minor
      Found in src/Tests/PHPUnit/Traits/LaravelCommandsAssertionsTrait.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 handle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function handle(QueryExecuted $event): void
          {
              try {
                  $bindings = (array)$event->bindings;
                  $duration = $event->time;
      Severity: Minor
      Found in src/Laravel/DatabaseQueriesLogger/QueryExecutedEventsListener.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 setUpTraits has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function setUpTraits(): array
          {
              $uses = parent::setUpTraits();
      
              if (
      Severity: Minor
      Found in src/Tests/PHPUnit/AbstractLaravelTestCase.php - About 25 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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct()
          {
              \set_exception_handler(function ($e) {
                  if ($e instanceof Exception || $e instanceof TypeError) {
                      echo \sprintf(
      Severity: Minor
      Found in src/Tests/Bootstrap/AbstractTestsBootstrapper.php - About 25 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 disconnectFromAllDatabaseConnections has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function disconnectFromAllDatabaseConnections(Application $app = null): bool
          {
              $result = false;
      
              /** @var Application $app */
      Severity: Minor
      Found in src/Tests/PHPUnit/Traits/WithDatabaseDisconnects.php - About 25 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