phug-php/phug

View on GitHub

Showing 171 of 197 total issues

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

    private function getRendererException($error, $code, $line, $offset, $source, $sourcePath, $parameters, $options)
    {
        $colorSupport = $options['color_support'];
        if (is_null($colorSupport)) {
            $colorSupport = $this->hasColorSupport();
Severity: Minor
Found in src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 1 hr to fix

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

        private function getProcesses($list, $link, $index, $duration, $maxSpace, $lineHeight, $timePrecision)
        {
            $count = count($list);
            for ($i = $count > 1 ? 1 : 0; $i < $count; $i++) {
                /** @var Event $previousEvent */
    Severity: Minor
    Found in src/Phug/Renderer/Renderer/Profiler/Profile.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 getRendererException has 8 arguments (exceeds 4 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 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                  if (!$checked ||
                      $this->isInExclusionContext($tokens, $index) ||
                      $this->isInFunctionParams($tokens, $index) ||
                      $this->isInKeywordParams($tokens, $index) ||
                      $this->isInComplexInterpolation($tokens, $index) ||
          Severity: Major
          Found in src/Phug/Formatter/Formatter/Partial/HandleVariable.php - About 1 hr to fix

            Function __call has a Cognitive Complexity of 9 (exceeds 5 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 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 isExpired has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function isExpired($file, &$cachePath = null)
                {
                    if (isset($this->options['up_to_date_check']) && !$this->options['up_to_date_check']) {
                        if (func_num_args() > 1) {
                            $cachePath = $this->getRegistryPath($file);
            Severity: Minor
            Found in src/Phug/Phug/Phug/Optimizer.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 getIndentLevel has a Cognitive Complexity of 9 (exceeds 5 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 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 9 (exceeds 5 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 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 analyze has a Cognitive Complexity of 9 (exceeds 5 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 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 addModule has a Cognitive Complexity of 9 (exceeds 5 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 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 withVariableReference has a Cognitive Complexity of 9 (exceeds 5 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 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 formatExpressionElement has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function formatExpressionElement(ExpressionElement $code)
                {
                    $value = $this->formatCode($code->getValue(), $code->isChecked(), !$code->isTransformationAllowed());
            
                    if ($code->hasStaticValue()) {
            Severity: Minor
            Found in src/Phug/Formatter/Formatter/AbstractFormat.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 loopScan has a Cognitive Complexity of 9 (exceeds 5 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 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 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function scan(State $state)
                {
                    $reader = $state->getReader();
            
                    if (!$reader->peekChar('<')) {
            Severity: Minor
            Found in src/Phug/Lexer/Lexer/Scanner/MarkupScanner.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 formatAttributes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function formatAttributes(MarkupElement $element)
                {
                    if ($this->hasNonStaticAttributes($element) ||
                        $this->hasDuplicateAttributeNames($element)) {
                        $empty = true;
            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 hasDuplicateAttributeNames has a Cognitive Complexity of 9 (exceeds 5 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 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

            Method getProcesses has 7 arguments (exceeds 4 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 50 mins to fix

              Method getSandboxCall has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private function getSandboxCall(&$source, $method, $path, $input, callable $getSource, array $parameters)
              Severity: Minor
              Found in src/Phug/Renderer/Renderer/Partial/AdapterTrait.php - About 45 mins to fix

                Method getDebuggedException has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private function getDebuggedException($error, $code, $source, $path, $parameters, $options)
                Severity: Minor
                Found in src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language