phug-php/phug

View on GitHub

Showing 171 of 197 total issues

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

    public function getEventListeners()
    {
        $eventListeners = array_map(function (callable $eventListener) {
            return function (Event $event) use ($eventListener) {
                if ($this->isAlive() && $eventListener($event) !== false) {
Severity: Minor
Found in src/Phug/Renderer/Renderer/Profiler/ProfilerModule.php - About 1 hr to fix

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

        public function __construct(Lexer $lexer, $input, array $options)
        {
            $this->lexer = $lexer;
            $this->setOptionsRecursive([
                'reader_class_name'        => Reader::class,
    Severity: Minor
    Found in src/Phug/Lexer/Lexer/State.php - About 1 hr to fix

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

          public function getDebugError($error, $code, $path = null)
          {
              /** @var \Throwable $error */
              $line = $this->getSourceLine($error);
              if ($line === false) {
      Severity: Minor
      Found in src/Phug/Formatter/Formatter.php - About 1 hr to fix

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

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

          Method compileNode has 29 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 getExposedProperties has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getExposedProperties($object, $deep)
                {
                    $result = "\n";
                    foreach (get_class_methods($object) as $method) {
                        if (mb_strlen($result) > 0x80000) {
            Severity: Minor
            Found in src/Phug/Renderer/Renderer/Profiler/Dump.php - About 1 hr to fix

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

                  public function renderDirectory($path, $destination = null, $extension = '.html', array $parameters = [])
                  {
                      if (is_array($destination)) {
                          $parameters = $destination;
                          $destination = null;
              Severity: Minor
              Found in src/Phug/Renderer/Renderer.php - About 1 hr to fix

                Method formatKeywordElement has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function formatKeywordElement(KeywordElement $element)
                    {
                        $name = $element->getName();
                        $keyword = $this->getOption(['keywords', $name]);
                        $result = call_user_func($keyword, $element->getValue(), $element, $name);
                Severity: Minor
                Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 hr to fix

                  Method getDefaultOptions has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function getDefaultOptions($options)
                      {
                          return [
                              'debug'                 => true,
                              'exit_on_error'         => true,
                  Severity: Minor
                  Found in src/Phug/Renderer/Renderer/Partial/RendererOptionsTrait.php - About 1 hr to fix

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

                        public function __construct(EventList $events, SplObjectStorage $nodesRegister)
                        {
                            $this->nodesRegister = $nodesRegister;
                    
                            if ($events) {
                    Severity: Minor
                    Found in src/Phug/Renderer/Renderer/Profiler/LinkedProcesses.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 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function scan(State $state)
                        {
                            $keywords = $state->getOption('keyword_names');
                    
                            if (count($keywords)) {
                    Severity: Minor
                    Found in src/Phug/Lexer/Lexer/Scanner/KeywordScanner.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 scanInterpolationTokens has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function scanInterpolationTokens(State $state, &$firstToken)
                        {
                            if (static::INTERPOLATION_ENABLED) {
                                foreach ($state->scan(InterpolationScanner::class) as $subToken) {
                                    if ($firstToken) {
                    Severity: Minor
                    Found in src/Phug/Lexer/Lexer/Scanner/TextScanner.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 compileNode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function compileNode(NodeInterface $node, ElementInterface $parent = null)
                        {
                            $nodeEvent = new NodeEvent($node);
                            $this->trigger($nodeEvent);
                            $node = $nodeEvent->getNode();
                    Severity: Minor
                    Found in src/Phug/Compiler/Compiler.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 calculateIndex has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function calculateIndex($lines, $min, $max)
                        {
                            $index = 0;
                            foreach ($lines as $level => $line) {
                                foreach ($line as $process) {
                    Severity: Minor
                    Found in src/Phug/Renderer/Renderer/Profiler/Profile.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 readString has a Cognitive Complexity of 10 (exceeds 5 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

                    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 isInFunctionParams has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function isInFunctionParams(&$tokens, $index)
                        {
                            $afterOpen = false;
                            for ($i = $index - 1; $i >= 0; $i--) {
                                if (in_array($tokens[$i], [')', '}'])) {
                    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

                    Method enableModules has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function enableModules()
                        {
                            /* @var ModuleContainerInterface $this */
                    
                            $this->addModules($this->getOption('modules'));
                    Severity: Minor
                    Found in src/Phug/Renderer/Renderer/Partial/RendererOptionsTrait.php - About 1 hr to fix

                      Method getIndentLevel has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getIndentLevel(State $state, $maxLevel = INF, callable $getIndentChar = null)
                          {
                              if ($maxLevel <= 0) {
                                  return 0;
                              }
                      Severity: Minor
                      Found in src/Phug/Lexer/Lexer/Scanner/IndentationScanner.php - About 1 hr to fix

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

                            public function handleToken(TokenInterface $token, State $state)
                            {
                                if (!($token instanceof AttributeToken)) {
                                    throw new \RuntimeException(
                                        'You can only pass attribute tokens to this token handler'
                        Severity: Minor
                        Found in src/Phug/Parser/Parser/TokenHandler/AttributeTokenHandler.php - About 1 hr to fix

                          Method getErrorAsHtml has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function getErrorAsHtml($error, $parameters, $data)
                              {
                                  $sandBox = new SandBox(function () use (
                                      $error,
                                      $parameters,
                          Severity: Minor
                          Found in src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language