kahlan/kahlan

View on GitHub

Showing 191 of 191 total issues

Method _functionNode has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function _functionNode()
    {
        $node = new FunctionDef();
        $token = $this->_stream->current(true);
        $parent = $this->_states['current'];
Severity: Minor
Found in src/Jit/Parser.php - About 1 hr to fix

    Method _classNode has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function _classNode()
        {
            if (substr($this->_states['body'], -2) === '::') { // Bails out on `::class`
                $this->_states['body'] .= 'class';
                return;
    Severity: Minor
    Found in src/Jit/Parser.php - About 1 hr to fix

      Method _renderMetricsReport has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function _renderMetricsReport($metricsReport, $labelWidth, $lineWidth, $depth)
          {
              $nbChilden = count($metricsReport);
              $index = 0;
              foreach ($metricsReport as $name => $data) {
      Severity: Minor
      Found in src/Reporter/Coverage.php - About 1 hr to fix

        Method debug has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function debug($content)
            {
                $root = is_object($content) ? $content : static::parse($content, ['lines' => true]);
                $result = '';
        
        
        Severity: Minor
        Found in src/Jit/Parser.php - About 1 hr to fix

          Method _reportSpecMessage has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function _reportSpecMessage($log)
              {
                  $messages = $log->messages();
                  $message = end($messages);
          
          
          Severity: Minor
          Found in src/Reporter/Terminal.php - About 1 hr to fix

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

                public static function export($options)
                {
                    $defaults = [
                        'collector'    => null,
                        'head'         => null,
            Severity: Minor
            Found in src/Reporter/Coverage/Exporter/CodeClimate.php - About 1 hr to fix

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

                  public static function errorType($value)
                  {
                      switch ($value) {
                          case E_ERROR:
                              return 'E_ERROR';
              Severity: Minor
              Found in src/Analysis/Debugger.php - About 1 hr to fix

                Method specEnd has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function specEnd($log = null)
                    {
                        $isOk = $log->passed() ? "ok" : "not ok";
                
                        switch ($log->type()) {
                Severity: Minor
                Found in src/Reporter/Tap.php - About 1 hr to fix

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

                  function box($name = '', $box = null)
                  {
                      static $boxes = [];
                  
                      if (func_num_args() === 1) {
                  Severity: Minor
                  Found in src/functions.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 _renderCoverage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function _renderCoverage($metrics)
                      {
                          $stats = $metrics->data();
                          foreach ($stats['files'] as $file) {
                              $this->write("File: {$file}" . "\n\n");
                  Severity: Minor
                  Found in src/Reporter/Coverage.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 _generateMethodStubs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected static function _generateMethodStubs($methods, $defaults = true)
                      {
                          $result = [];
                          $methods = $methods !== null ? (array) $methods : [];
                  
                  
                  Severity: Minor
                  Found in src/Plugin/Double.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

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

                      public function where($requirements = [])
                      {
                          foreach ($requirements as $name => $args) {
                              if (!isset($this->_chain[$name])) {
                                  throw new InvalidArgumentException("Unexisting `{$name}` as method as part of the chain definition.");
                  Severity: Major
                  Found in src/Plugin/Stub.php and 1 other location - About 1 hr to fix
                  src/Matcher/ToReceive.php on lines 216..228

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

                  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 where($requirements = [])
                      {
                          foreach ($requirements as $name => $args) {
                              if (!isset($this->_messages[$name])) {
                                  throw new InvalidArgumentException("Unexisting `{$name}` as method as part of the chain definition.");
                  Severity: Major
                  Found in src/Matcher/ToReceive.php and 1 other location - About 1 hr to fix
                  src/Plugin/Stub.php on lines 210..222

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

                  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 add has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function add($prefix, $paths, $prepend = false)
                      {
                          if (!$prefix) {
                              if ($prepend) {
                                  $this->_fallbackDirsPsr0 = array_merge(
                  Severity: Minor
                  Found in src/Jit/ClassLoader.php - About 1 hr to fix

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

                        public function addPsr4($prefix, $paths, $prepend = false)
                        {
                            if (!$prefix) {
                                // Register directories for the root namespace.
                                if ($prepend) {
                    Severity: Minor
                    Found in src/Jit/ClassLoader.php - About 1 hr to fix

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

                          protected function _coverage($file, $coverage)
                          {
                              $result = [];
                              $root = $this->parse($file);
                              foreach ($root->lines['content'] as $num => $content) {
                      Severity: Minor
                      Found in src/Reporter/Coverage/Collector.php - About 1 hr to fix

                        Method _coverage has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                protected function _coverage()
                                {
                                    return Filters::run($this, 'coverage', [], function ($chain) {
                                        if (!$this->commandLine()->exists('coverage')) {
                                            return;
                        Severity: Minor
                        Found in src/Cli/Kahlan.php - About 1 hr to fix

                          Method patched has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function patched($namespace, $className, $methodName, &$substitute = null)
                              {
                                  $name = $className ?: $methodName;
                          
                                  if ($namespace && ($className || function_exists("{$namespace}\\{$name}"))) {
                          Severity: Minor
                          Found in src/Plugin/Monkey.php - About 1 hr to fix

                            Method _buildDescription has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function _buildDescription($startIndex = 0)
                                {
                                    $times = $this->times();
                            
                                    $report = $this->_report;
                            Severity: Minor
                            Found in src/Matcher/ToReceive.php - About 1 hr to fix

                              Method match has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static function match($actual, $expected)
                                  {
                                      $args = func_get_args();
                                      $expected = count($args) > 2 ? array_slice($args, 1) : $expected;
                                      $expected = (array) $expected;
                              Severity: Minor
                              Found in src/Matcher/ToContainKey.php - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language