phug-php/phug

View on GitHub

Showing 115 of 115 total issues

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, true)) {
                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 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

          Method scan has 36 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

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

                protected function provideAttributesAssignment()
                {
                    return $this
                        ->registerHelper(
                            'attributes_mapping',
            Severity: Minor
            Found in src/Phug/Formatter/Formatter/Partial/AssignmentHelpersTrait.php - About 1 hr to fix

              Function scan has a Cognitive Complexity of 14 (exceeds 7 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 7 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

              Function scan has a Cognitive Complexity of 14 (exceeds 7 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

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

                  public function setFormatter(Formatter $formatter)
                  {
                      $this->formatter = $formatter;
                      $format = $this;
              
              
              Severity: Minor
              Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 hr to fix

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

                    protected function formatElementChildren(ElementInterface $element, $indentStep = 1)
                    {
                        $indentLevel = $this->formatter->getLevel();
                        $this->formatter->setLevel($indentLevel + $indentStep);
                        $content = '';
                Severity: Minor
                Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 hr to fix

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

                      public static function getList()
                      {
                          return [
                              //TODO: Several of these are non-standard and need to be encapsulated into extensions
                              //Namely: ForScanner, DoScanner, VariableScanner
                  Severity: Minor
                  Found in src/Phug/Lexer/Scanners.php - About 1 hr to fix

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

                        public function compileNode(NodeInterface $node, ElementInterface $parent = null)
                        {
                            $compiler = $this->getCompiler();
                            $compiler->assert(
                                $node instanceof FilterNode,
                    Severity: Minor
                    Found in src/Phug/Compiler/Compiler/NodeCompiler/FilterNodeCompiler.php - About 1 hr to fix

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

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

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

                            public function compileNode(NodeInterface $node, ElementInterface $parent = null)
                            {
                                $compiler = $this->getCompiler();
                                $compiler->assert(
                                    $node instanceof ElementNode,
                        Severity: Minor
                        Found in src/Phug/Compiler/Compiler/NodeCompiler/ElementNodeCompiler.php - About 1 hr to fix

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

                              public function readString(array $escapeSequences = null, $raw = false)
                              {
                                  if (!$this->peekQuote()) {
                                      return;
                                  }
                          Severity: Minor
                          Found in src/Phug/Reader/Reader.php - About 1 hr to fix

                            Function getNodeName has a Cognitive Complexity of 13 (exceeds 7 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 findChildren has a Cognitive Complexity of 13 (exceeds 7 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 hasNonStaticAttributes has a Cognitive Complexity of 13 (exceeds 7 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 isInExclusionContext has a Cognitive Complexity of 13 (exceeds 7 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

                            Severity
                            Category
                            Status
                            Source
                            Language