phug-php/phug

View on GitHub

Showing 171 of 197 total issues

Method compose has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function compose($timePrecision, $lineHeight)
    {
        $duration = microtime(true) - $this->startTime;
        $linkedProcesses = new LinkedProcesses($this->events, $this->nodesRegister);

Severity: Minor
Found in src/Phug/Renderer/Renderer/Profiler/Profile.php - About 1 hr to fix

    Method readExpression has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function readExpression(array $breaks = null, array $brackets = null)
        {
            if (!$this->hasLength()) {
                return;
            }
    Severity: Minor
    Found in src/Phug/Reader/Reader.php - About 1 hr to fix

      Method formatAttributeElement has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function formatAttributeElement(AttributeElement $element)
          {
              $value = $element->getValue();
              $name = $element->getName();
              $nonEmptyAttribute = ($name === 'class' || $name === 'id');
      Severity: Minor
      Found in src/Phug/Formatter/Formatter/Format/XmlFormat.php - About 1 hr to fix

        Method displayFile has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function displayFile($__pug_file, array $__pug_parameters = [])
            {
                if ($this->isExpired($__pug_file, $__pug_cache_file)) {
                    if (isset($this->options['render'])) {
                        call_user_func($this->options['render'], $__pug_file, $__pug_parameters, $this->options);
        Severity: Minor
        Found in src/Phug/Phug/Phug/Optimizer.php - About 1 hr to fix

          Function scan has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public function scan(State $state)
              {
                  $reader = $state->getReader();
          
                  //Text block on tags etc. (p. some text|p!. some text)
          Severity: Minor
          Found in src/Phug/Lexer/Lexer/Scanner/SubScanner.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 displayFile has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public function displayFile($__pug_file, array $__pug_parameters = [])
              {
                  if ($this->isExpired($__pug_file, $__pug_cache_file)) {
                      if (isset($this->options['render'])) {
                          call_user_func($this->options['render'], $__pug_file, $__pug_parameters, $this->options);
          Severity: Minor
          Found in src/Phug/Phug/Phug/Optimizer.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 initProperties has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function initProperties($name, $events)
              {
                  $style = [];
                  foreach ([
                      ['current', EndLexEvent::class, 'lexing', [
          Severity: Minor
          Found in src/Phug/Renderer/Renderer/Profiler/LinkDump.php - About 1 hr to fix

            Method getSourceLine has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getSourceLine($error)
                {
                    $previous = null;
                    $line = null;
            
            
            Severity: Minor
            Found in src/Phug/Formatter/Formatter.php - About 1 hr to fix

              Method handleTokens has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function handleTokens($code, $checked)
                  {
                      $phpTokenHandler = $this->getOption('php_token_handlers');
                      $untouched = false;
              
              
              Severity: Minor
              Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 hr to fix

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

                    public function scan(State $state)
                    {
                        $reader = $state->getReader();
                
                        foreach ($state->scanToken(
                Severity: Minor
                Found in src/Phug/Lexer/Lexer/Scanner/FilterScanner.php - About 1 hr to fix

                  Function findChildren has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function findChildren(callable $callback, $depth = null, $level = null)
                      {
                          $level = $level ?: 0;
                  
                          foreach ($this->children as $child) {
                  Severity: Minor
                  Found in src/Phug/Ast/Ast/Node.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 getNodeName has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function getNodeName(NodeInterface $node)
                      {
                          switch (get_class($node)) {
                              case ElementNode::class:
                                  $text = get_class($node);
                  Severity: Minor
                  Found in src/Phug/Parser/Parser.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 isInExclusionContext has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function isInExclusionContext(&$tokens, $index)
                      {
                          foreach ([
                              // Exclude tokens before the variables
                              -1 => [
                  Severity: Minor
                  Found in src/Phug/Formatter/Formatter/Partial/HandleVariable.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 hasNonStaticAttributes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function hasNonStaticAttributes(MarkupInterface $element)
                      {
                          if ($element instanceof MarkupElement || $element instanceof MixinCallElement) {
                              foreach ($element->getAttributes() as $attribute) {
                                  if ($attribute->hasStaticMember('value')) {
                  Severity: Minor
                  Found in src/Phug/Formatter/Formatter/Format/XmlFormat.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 yieldAssignmentElement has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function yieldAssignmentElement(AssignmentElement $element)
                      {
                          foreach ($this->getOption('assignment_handlers') as $handler) {
                              $iterator = $handler($element) ?: [];
                  
                  
                  Severity: Minor
                  Found in src/Phug/Formatter/Formatter/Format/XmlFormat.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 addModule has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function addModule($module)
                      {
                          if ($module instanceof ModuleInterface) {
                              if (in_array($module, $this->modules)) {
                                  throw new InvalidArgumentException(
                  Severity: Minor
                  Found in src/Phug/Util/Util/Partial/ModuleContainerTrait.php - About 1 hr to fix

                    Method initDebugOptions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function initDebugOptions(Renderer $profilerContainer)
                        {
                            $profilerContainer->setOptionsDefaults([
                                'memory_limit'       => $profilerContainer->getOption('debug') ? 0x3200000 : -1, // 50MB by default in debug
                                'execution_max_time' => $profilerContainer->getOption('debug') ? 30000 : -1, // 30s by default in debug
                    Severity: Minor
                    Found in src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 1 hr to fix

                      Method handleToken has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function handleToken(TokenInterface $token, State $state)
                          {
                              if (!($token instanceof InterpolationStartToken)) {
                                  throw new \RuntimeException(
                                      'You can only pass interpolation start tokens to this token handler'

                        Method getNodeName has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function getNodeName(NodeInterface $node)
                            {
                                switch (get_class($node)) {
                                    case ElementNode::class:
                                        $text = get_class($node);
                        Severity: Minor
                        Found in src/Phug/Parser/Parser.php - About 1 hr to fix

                          Method lex has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function lex($input, $path = null)
                              {
                                  $stateClassName = $this->getOption('lexer_state_class_name');
                                  $lexEvent = new LexEvent($input, $path, $stateClassName, [
                                      'encoding'                 => $this->getOption('encoding'),
                          Severity: Minor
                          Found in src/Phug/Lexer/Lexer.php - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language