phug-php/phug

View on GitHub

Showing 113 of 115 total issues

Function handleError has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

    public function handleError($error, $code, $path, $source, $parameters, $options)
    {
        /* @var \Throwable $error */
        $exception = $options['debug']
            ? $this->getDebuggedException($error, $code, $source, $path, $parameters, $options)
Severity: Minor
Found in src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 55 mins 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 isBlockTag has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

    protected function isBlockTag(MarkupInterface $element)
    {
        if ($element->belongsTo($this->getOption('inline_tags'))) {
            return false;
        }
Severity: Minor
Found in src/Phug/Formatter/Formatter/Format/XhtmlFormat.php - About 55 mins 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 11 (exceeds 7 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 55 mins 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 7 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 45 mins 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 7 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 45 mins 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 __construct has a Cognitive Complexity of 10 (exceeds 7 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 45 mins 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 7 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 45 mins 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 getRendererException has 8 arguments (exceeds 6 allowed). Consider refactoring.
Open

    private function getRendererException($error, $code, $line, $offset, $source, $sourcePath, $parameters, $options)
Severity: Major
Found in src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 45 mins to fix

    Function compileNode has a Cognitive Complexity of 10 (exceeds 7 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 45 mins 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 7 allowed). Consider refactoring.
    Open

        private function isInFunctionParams(&$tokens, $index)
        {
            $afterOpen = false;
            for ($i = $index - 1; $i >= 0; $i--) {
                if (in_array($tokens[$i], [')', '}'], true)) {
    Severity: Minor
    Found in src/Phug/Formatter/Formatter/Partial/HandleVariable.php - About 45 mins 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 7 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 45 mins 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 getProcesses has 7 arguments (exceeds 6 allowed). Consider refactoring.
    Open

        private function getProcesses($list, $link, $index, $duration, $maxSpace, $lineHeight, $timePrecision)
    Severity: Major
    Found in src/Phug/Renderer/Renderer/Profiler/Profile.php - About 35 mins to fix

      Function scan has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
      Open

          public function scan(State $state)
          {
              foreach ($state->scanToken(
                  BlockToken::class,
                  'block(?:[\t ]+(?<mode>append|prepend|replace))?'.
      Severity: Minor
      Found in src/Phug/Lexer/Lexer/Scanner/BlockScanner.php - About 35 mins 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 __call has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
      Open

          public function __call($method, $parameters)
          {
              if ($this instanceof OptionInterface && $this->hasOption('macros')) {
                  $macros = $this->getOption('macros') ?: [];
                  if (isset($macros[$method])) {
      Severity: Minor
      Found in src/Phug/Util/Util/Partial/MacroableTrait.php - About 35 mins 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 withVariableReference has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
      Open

          private function withVariableReference(&$variable, $name, $callback)
          {
              $keys = $this->handleOptionName($name);
              if (is_array($keys)) {
                  foreach (array_slice($keys, 0, -1) as $key) {
      Severity: Minor
      Found in src/Phug/Util/Util/Partial/OptionTrait.php - About 35 mins 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 addModule has a Cognitive Complexity of 9 (exceeds 7 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 35 mins 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 analyze has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
      Open

          public function analyze($quitOnOutdent, array $breakChars = [])
          {
              $this->outdent = false;
              $this->level = $this->state->getLevel();
              $this->newLevel = $this->level;
      Severity: Minor
      Found in src/Phug/Lexer/Lexer/Analyzer/LineAnalyzer.php - About 35 mins 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 loopScan has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
      Open

          public function loopScan($scanners, $required = false)
          {
              if ($this->reader->hasLength() && $this->scanners === null) {
                  $this->scanners = $this->filterScanners($scanners);
              }
      Severity: Minor
      Found in src/Phug/Lexer/Lexer/State.php - About 35 mins 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 hasDuplicateAttributeNames has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
      Open

          protected function hasDuplicateAttributeNames(MarkupInterface $element)
          {
              if ($element instanceof MarkupElement || $element instanceof MixinCallElement) {
                  $names = [];
                  foreach ($element->getAttributes() as $attribute) {
      Severity: Minor
      Found in src/Phug/Formatter/Formatter/Format/XmlFormat.php - About 35 mins 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 yieldLines has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
      Open

          private function yieldLines(State $state, array $lines, LineAnalyzer $analyzer)
          {
              yield $state->createToken(IndentToken::class);
      
              $maxIndent = $analyzer->getMaxIndent();
      Severity: Minor
      Found in src/Phug/Lexer/Lexer/Scanner/MultilineScanner.php - About 35 mins 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