mlively/Phake

View on GitHub

Showing 46 of 46 total issues

Phake has 46 functions (exceeds 20 allowed). Consider refactoring.
Open

class Phake
{
    private static ?Phake\Facade $phake = null;

    private static ?Phake\Client\IClient $client = null;
Severity: Minor
Found in src/Phake.php - About 6 hrs to fix

    File MockClass.php has 369 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /*
     * Phake - Mocking Framework
     *
     * Copyright (c) 2010-2022, Mike Lively <m@digitalsandwich.com>
    Severity: Minor
    Found in src/Phake/ClassGenerator/MockClass.php - About 4 hrs to fix

      File Phake.php has 337 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /*
       * Phake - Mocking Framework
       *
       * Copyright (c) 2010-2022, Mike Lively <m@digitalsandwich.com>
      Severity: Minor
      Found in src/Phake.php - About 4 hrs to fix

        Function generate has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            public function generate(string $newClassName, string|array $mockedClassName, \Phake\Mock\InfoRegistry $infoRegistry): void
            {
                $extends    = '';
                $implements = '';
                $interfaces = [];
        Severity: Minor
        Found in src/Phake/ClassGenerator/MockClass.php - About 3 hrs 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 verifyCall has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            public function verifyCall(CallExpectation $expectation): VerifierResult
            {
                $matcher = new \Phake\Matchers\MethodMatcher($expectation->getMethod(), $expectation->getArgumentMatcher());
                $calls   = $this->recorder->getAllCalls();
        
        
        Severity: Minor
        Found in src/Phake/CallRecorder/Verifier.php - About 2 hrs 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 generate has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function generate(string $newClassName, string|array $mockedClassName, \Phake\Mock\InfoRegistry $infoRegistry): void
            {
                $extends    = '';
                $implements = '';
                $interfaces = [];
        Severity: Major
        Found in src/Phake/ClassGenerator/MockClass.php - About 2 hrs to fix

          Function resolveNamedArguments has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              private function resolveNamedArguments(\Phake\IMock|string $object, string $method, array $arguments): array
              {
                  $positionalArguments = [];
                  $namedArguments      = [];
                  foreach ($arguments as $key => $arg) {
          Severity: Minor
          Found in src/Phake/Proxies/NamedArgumentsResolver.php - About 2 hrs 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 verifyNoOtherCalls(): VerifierResult
              {
                  $result = true;
          
                  $reportedCalls = [];
          Severity: Major
          Found in src/Phake/CallRecorder/Verifier.php and 1 other location - About 2 hrs to fix
          src/Phake/CallRecorder/Verifier.php on lines 127..144

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

          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 verifyNoCalls(): VerifierResult
              {
                  $result = true;
          
                  $reportedCalls = [];
          Severity: Major
          Found in src/Phake/CallRecorder/Verifier.php and 1 other location - About 2 hrs to fix
          src/Phake/CallRecorder/Verifier.php on lines 149..166

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

          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 verifyNoInteraction(Phake\IMock ...$mocks): void
              {
                  foreach ($mocks as $mock) {
                      $callRecorder = Phake::getInfo($mock)->getCallRecorder();
                      $verifier = new Phake\CallRecorder\Verifier($callRecorder, $mock);
          Severity: Major
          Found in src/Phake.php and 1 other location - About 2 hrs to fix
          src/Phake.php on lines 245..256

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

          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 verifyNoOtherInteractions(Phake\IMock ...$mocks): void
              {
                  foreach ($mocks as $mock) {
                      $callRecorder = Phake::getInfo($mock)->getCallRecorder();
                      $verifier = new Phake\CallRecorder\Verifier($callRecorder, $mock);
          Severity: Major
          Found in src/Phake.php and 1 other location - About 2 hrs to fix
          src/Phake.php on lines 228..239

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

          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

          Method implementMethod has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function implementMethod(\ReflectionMethod $method, bool $static = false): string
              {
                  $modifiers = implode(
                      ' ',
                      \Reflection::getModifierNames($method->getModifiers() & ~\ReflectionMethod::IS_ABSTRACT)
          Severity: Major
          Found in src/Phake/ClassGenerator/MockClass.php - About 2 hrs to fix

            Function reflectionTypeToString has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                private function reflectionTypeToString(\ReflectionType $type, \ReflectionClass $selfClass): string
                {
                    $result = '';
                    $nullable = '';
            
            
            Severity: Minor
            Found in src/Phake/ClassGenerator/MockClass.php - About 2 hrs 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 setClient has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function setClient(Phake\Client\IClient|string|null $client): void
                {
                    if ($client instanceof Phake\Client\IClient) {
                        self::$client = $client;
                    } elseif (self::CLIENT_PHPUNIT8 == $client) {
            Severity: Minor
            Found in src/Phake.php - About 2 hrs 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 verifyCall has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function verifyCall(CallExpectation $expectation): VerifierResult
                {
                    $matcher = new \Phake\Matchers\MethodMatcher($expectation->getMethod(), $expectation->getArgumentMatcher());
                    $calls   = $this->recorder->getAllCalls();
            
            
            Severity: Minor
            Found in src/Phake/CallRecorder/Verifier.php - About 1 hr to fix

              Method getReturnTypeResult has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getReturnTypeResult(?\ReflectionType $returnType, \ReflectionMethod $method): mixed
                  {
                      if (null === $returnType) {
                          return null;
                      } elseif ($returnType instanceof \ReflectionNamedType) {
              Severity: Minor
              Found in src/Phake/Stubber/Answers/SmartDefaultAnswer.php - About 1 hr to fix

                Method resolveNamedArguments has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function resolveNamedArguments(\Phake\IMock|string $object, string $method, array $arguments): array
                    {
                        $positionalArguments = [];
                        $namedArguments      = [];
                        foreach ($arguments as $key => $arg) {
                Severity: Minor
                Found in src/Phake/Proxies/NamedArgumentsResolver.php - About 1 hr to fix

                  Method reflectionTypeToString has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function reflectionTypeToString(\ReflectionType $type, \ReflectionClass $selfClass): string
                      {
                          $result = '';
                          $nullable = '';
                  
                  
                  Severity: Minor
                  Found in src/Phake/ClassGenerator/MockClass.php - About 1 hr to fix

                    Function getReturnTypeResult has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function getReturnTypeResult(?\ReflectionType $returnType, \ReflectionMethod $method): mixed
                        {
                            if (null === $returnType) {
                                return null;
                            } elseif ($returnType instanceof \ReflectionNamedType) {
                    Severity: Minor
                    Found in src/Phake/Stubber/Answers/SmartDefaultAnswer.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 doArgumentsMatch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function doArgumentsMatch(array &$arguments): void
                        {
                            $argumentCopy = $arguments;
                            $nextArgument = null;
                    
                    
                    Severity: Minor
                    Found in src/Phake/Matchers/SingleArgumentMatcher.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

                    Severity
                    Category
                    Status
                    Source
                    Language