swaggest/api-compat

View on GitHub

Showing 7 of 7 total issues

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

    public static function fitsPattern($path, $pattern)
    {
        $path = explode('/', $path);
        $pattern = explode('/', $pattern);

Severity: Minor
Found in src/Path.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 checkModifications has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkModifications()
    {
        foreach ($this->jsonDiff->getModifiedPaths() as $path) {
            $original = JsonPointer::getByPointer($this->original, $path);
            $new = JsonPointer::getByPointer($this->new, $path);
Severity: Minor
Found in src/ApiCompat.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 checkModifications has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function checkModifications()
    {
        foreach ($this->jsonDiff->getModifiedPaths() as $path) {
            $original = JsonPointer::getByPointer($this->original, $path);
            $new = JsonPointer::getByPointer($this->new, $path);
Severity: Minor
Found in src/ApiCompat.php - About 1 hr to fix

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

        private function checkAdditions()
        {
            foreach ($this->jsonDiff->getAddedPaths() as $path) {
                $new = JsonPointer::getByPointer($this->new, $path);
                switch (true) {
    Severity: Minor
    Found in src/ApiCompat.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

    Avoid too many return statements within this method.
    Open

            return true;
    Severity: Major
    Found in src/Path.php - About 30 mins to fix

      Function performAction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function performAction()
          {
              $originalJson = file_get_contents($this->originalPath);
              if (!$originalJson) {
                  $this->response->error('Unable to read ' . $this->originalPath);
      Severity: Minor
      Found in src/Cli/ApiCompatCmd.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 checkRemovals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private function checkRemovals()
          {
              foreach ($this->jsonDiff->getRemovedPaths() as $path) {
                  $original = JsonPointer::getByPointer($this->original, $path);
                  switch (true) {
      Severity: Minor
      Found in src/ApiCompat.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