phug-php/phug

View on GitHub

Showing 171 of 197 total issues

Method assert has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function assert($condition, $message, $node = null, $code = 0, $previous = null)
Severity: Minor
Found in src/Phug/Compiler/Compiler.php - About 35 mins to fix

    Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            SourceLocation $location,
            $message = '',
            $code = 0,
            TokenInterface $relatedToken = null,
            $previous = null
    Severity: Minor
    Found in src/Phug/Parser/ParserException.php - About 35 mins to fix

      Function dumpParameters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function dumpParameters()
          {
              $parameters = [];
              foreach ($this->getParameters() as $parameter) {
                  $string = '';
      Severity: Minor
      Found in src/Phug/DependencyInjection/DependencyInjection/FunctionWrapper.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 scan has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function scan(State $state)
          {
              $reader = $state->getReader();
      
              while ($reader->match($this->regExp)) {
      Severity: Minor
      Found in src/Phug/Lexer/Lexer/Scanner/InterpolationScanner.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 __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct(Formatter $formatter = null)
          {
              $patterns = [
                  'class_attribute'        => static::CLASS_ATTRIBUTE,
                  'string_attribute'       => static::STRING_ATTRIBUTE,
      Severity: Minor
      Found in src/Phug/Formatter/Formatter/AbstractFormat.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 scan has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function scan(State $state)
          {
              $reader = $state->getReader();
      
              foreach ($state->scan(TextScanner::class) as $token) {
      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

      Function locate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function locate($path, array $locations, array $extensions)
          {
              // @ catch softly PHP open_basedir restriction
              if (@is_file($path)) {
                  return is_readable($path) ? realpath($path) : null;
      Severity: Minor
      Found in src/Phug/Compiler/Compiler/Locator/FileLocator.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 __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct($options = null)
          {
              $this->initFormats()->setOptionsDefaults($options ?: [], [
                  'debug'                        => false,
                  'located_exception_class_name' => LocatedException::class,
      Severity: Minor
      Found in src/Phug/Formatter/Formatter.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 __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct($options = null)
          {
              $this->setOptionsDefaults($options ?: [], [
                  'lexer_class_name'        => Lexer::class,
                  'parser_state_class_name' => State::class,
      Severity: Minor
      Found in src/Phug/Parser/Parser.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 getExtensionsOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function getExtensionsOptions(array $extensions, array $options = [])
          {
              $methods = static::getExtensionsGetters();
      
              foreach ($extensions as $extensionClassName) {
      Severity: Minor
      Found in src/Phug/Phug/Phug/Partial/ExtensionsTrait.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 renderDirectory has a Cognitive Complexity of 7 (exceeds 5 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 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 scan has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function scan(State $state)
          {
              foreach (parent::scan($state) as $token) {
                  if ($token instanceof ConditionalToken) {
                      //Make sure spaces are replaced from `elseif`/`else if` to make a final keyword, "elseif"
      Severity: Minor
      Found in src/Phug/Lexer/Lexer/Scanner/ConditionalScanner.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 __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct($options = null)
          {
              $this->setOptionsDefaults($options ?: [], [
                  'paths'                      => [],
                  'debug'                      => false,
      Severity: Minor
      Found in src/Phug/Compiler/Compiler.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 readAssignOperator has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private function readAssignOperator(Reader $reader, AttributeToken $token)
          {
              return ($reader->peekString('?!=') && $token->unescape() && $token->uncheck() ||
                  $reader->peekString('?=') && $token->uncheck() ||
                  $reader->peekString('!=') && $token->unescape() ||
      Severity: Minor
      Found in src/Phug/Lexer/Lexer/Scanner/AttributeScanner.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 dump has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function dump()
          {
              $name = preg_replace('/^Phug\\\\.*\\\\([^\\\\]+)Element$/', '$1', get_class($this));
              if (method_exists($this, 'getName')) {
                  $name .= ': '.$this->getName();
      Severity: Minor
      Found in src/Phug/Formatter/Formatter/AbstractElement.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

      Avoid too many return statements within this method.
      Open

              return false;
      Severity: Major
      Found in src/Phug/Formatter/Formatter.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return $this->cache[$cacheKey];
        Severity: Major
        Found in src/Phug/DependencyInjection/DependencyInjection.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return $this->pattern(
                      'attribute_pattern',
                      $this->format($name),
                      $this->format($value)
                  );
          Severity: Major
          Found in src/Phug/Formatter/Formatter/Format/XmlFormat.php - About 30 mins to fix

            Function extractExtensionOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function extractExtensionOptions(&$options, $extensionClassName, $methods)
                {
                    foreach (['getOptions', 'getEvents'] as $method) {
                        $value = static::getExtensionMethodResult($extensionClassName, $method);
            
            
            Severity: Minor
            Found in src/Phug/Phug/Phug/Partial/ExtensionsTrait.php - About 25 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 compileNode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function compileNode(NodeInterface $node, ElementInterface $parent = null)
                {
                    $this->getCompiler()->assert(
                        $node instanceof ForNode,
                        'Unexpected '.get_class($node).' given to for compiler.',
            Severity: Minor
            Found in src/Phug/Compiler/Compiler/NodeCompiler/ForNodeCompiler.php - About 25 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