phug-php/phug

View on GitHub

Showing 171 of 197 total issues

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

    public function __construct($options = null)
    {
        $this->setOptionsDefaults($options ?: [], [
            'lexer_class_name'        => Lexer::class,
            'parser_state_class_name' => State::class,
Severity: Major
Found in src/Phug/Parser/Parser.php - About 3 hrs to fix

    File ProfilerModule.php has 296 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Phug\Renderer\Profiler;
    
    use Phug\Compiler\Event\CompileEvent;
    Severity: Minor
    Found in src/Phug/Renderer/Renderer/Profiler/ProfilerModule.php - About 3 hrs to fix

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

          public function __construct(Formatter $formatter = null)
          {
              $patterns = [
                  'class_attribute'        => static::CLASS_ATTRIBUTE,
                  'string_attribute'       => static::STRING_ATTRIBUTE,
      Severity: Major
      Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 2 hrs to fix

        Function scanDirectory has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

            public function scanDirectory($directory, $extensions = null, $directoryCallback = null, $fileCallback = null)
            {
                if ($extensions === null) {
                    $extensions = $this->getOption('extensions');
                }
        Severity: Minor
        Found in src/Phug/Renderer/Renderer/Partial/FileSystemTrait.php - About 2 hrs 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

        Formatter has 25 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Formatter implements ModuleContainerInterface
        {
            use LevelTrait;
            use ModuleContainerTrait;
        
        
        Severity: Minor
        Found in src/Phug/Formatter/Formatter.php - About 2 hrs to fix

          File DebuggerTrait.php has 277 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          namespace Phug\Renderer\Partial\Debug;
          
          use Phug\Formatter;
          Severity: Minor
          Found in src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 2 hrs to fix

            File Node.php has 275 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            namespace Phug\Ast;
            
            use InvalidArgumentException;
            Severity: Minor
            Found in src/Phug/Ast/Ast/Node.php - About 2 hrs to fix

              Function removeOptions has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function removeOptions($path, $options)
                  {
                      if (self::$renderer && (empty($path) || self::$renderer->hasOption($path))) {
                          if (is_array($options)) {
                              foreach ($options as $key => $value) {
              Severity: Minor
              Found in src/Phug/Phug/Phug/Phug.php - About 2 hrs 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 handleTokens has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function handleTokens($code, $checked)
                  {
                      $phpTokenHandler = $this->getOption('php_token_handlers');
                      $untouched = false;
              
              
              Severity: Minor
              Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 2 hrs 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

              ProfilerModule has 23 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class ProfilerModule extends AbstractModule
              {
                  /**
                   * @var int
                   */
              Severity: Minor
              Found in src/Phug/Renderer/Renderer/Profiler/ProfilerModule.php - About 2 hrs to fix

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

                    public function __construct(Formatter $formatter = null)
                    {
                        $this->setOptionsRecursive([
                            'white_space_sensitive_tags' => [
                                'pre',
                Severity: Major
                Found in src/Phug/Formatter/Formatter/Format/XhtmlFormat.php - About 2 hrs to fix

                  Function getExposedProperties has a Cognitive Complexity of 18 (exceeds 5 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 2 hrs 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 formatAttributeElement has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function formatAttributeElement(AttributeElement $element)
                      {
                          $value = $element->getValue();
                          $name = $element->getName();
                          $nonEmptyAttribute = ($name === 'class' || $name === 'id');
                  Severity: Minor
                  Found in src/Phug/Formatter/Formatter/Format/XmlFormat.php - About 2 hrs 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 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function scan(State $state)
                      {
                          $reader = $state->getReader();
                  
                          if ($reader->match('(?<raw>\!)?#\{')) {
                  Severity: Minor
                  Found in src/Phug/Lexer/Lexer/Scanner/DynamicTagScanner.php - About 2 hrs 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 17 (exceeds 5 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 2 hrs 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 isInExclusionContext has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function isInExclusionContext(&$tokens, $index)
                      {
                          foreach ([
                              // Exclude tokens before the variables
                              -1 => [
                  Severity: Major
                  Found in src/Phug/Formatter/Formatter/Partial/HandleVariable.php - About 2 hrs to fix

                    Method parse has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function parse($input, $path = null)
                        {
                            $stateClassName = $this->getOption('parser_state_class_name');
                    
                            $event = new ParseEvent($input, $path, $stateClassName, [
                    Severity: Major
                    Found in src/Phug/Parser/Parser.php - About 2 hrs to fix

                      Function getErrorMessage has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function getErrorMessage($error, SourceLocation $location, $data)
                          {
                              /* @var \Throwable $error */
                              $source = explode("\n", rtrim($data->source));
                              $errorType = get_class($error);
                      Severity: Minor
                      Found in src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 2 hrs 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 __construct has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function __construct($options = null)
                          {
                              $this->initFormats()->setOptionsDefaults($options ?: [], [
                                  'debug'                        => false,
                                  'located_exception_class_name' => LocatedException::class,
                      Severity: Major
                      Found in src/Phug/Formatter/Formatter.php - About 2 hrs to fix

                        Method getErrorMessage has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function getErrorMessage($error, SourceLocation $location, $data)
                            {
                                /* @var \Throwable $error */
                                $source = explode("\n", rtrim($data->source));
                                $errorType = get_class($error);
                        Severity: Minor
                        Found in src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language