phug-php/phug

View on GitHub

Showing 113 of 115 total issues

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 removeOptions has a Cognitive Complexity of 19 (exceeds 7 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 7 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

    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 getExposedProperties has a Cognitive Complexity of 18 (exceeds 7 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 7 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

        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

            Method compose has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function compose($timePrecision, $lineHeight)
                {
                    $duration = microtime(true) - $this->startTime;
                    $linkedProcesses = new LinkedProcesses($this->events, $this->nodesRegister);
            
            
            Severity: Minor
            Found in src/Phug/Renderer/Renderer/Profiler/Profile.php - About 1 hr to fix

              Method formatAttributeElement has 48 lines of code (exceeds 25 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 1 hr to fix

                Method readExpression has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function readExpression(array $breaks = null, array $brackets = null)
                    {
                        if (!$this->hasLength()) {
                            return;
                        }
                Severity: Minor
                Found in src/Phug/Reader/Reader.php - About 1 hr to fix

                  Function scan has a Cognitive Complexity of 17 (exceeds 7 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 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 displayFile has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function displayFile($__pug_file, array $__pug_parameters = [])
                      {
                          if ($this->isExpired($__pug_file, $__pug_cache_file)) {
                              if (isset($this->options['render'])) {
                                  call_user_func($this->options['render'], $__pug_file, $__pug_parameters, $this->options);
                  Severity: Minor
                  Found in src/Phug/Phug/Phug/Optimizer.php - About 1 hr to fix

                    Function getErrorMessage has a Cognitive Complexity of 16 (exceeds 7 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 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 handleTokens has 41 lines of code (exceeds 25 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 1 hr to fix

                      Method initProperties has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function initProperties($name, $events)
                          {
                              $style = [];
                              foreach ([
                                  ['current', EndLexEvent::class, 'lexing', [
                      Severity: Minor
                      Found in src/Phug/Renderer/Renderer/Profiler/LinkDump.php - About 1 hr to fix

                        Method getSourceLine has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function getSourceLine($error)
                            {
                                $previous = null;
                                $line = null;
                        
                        
                        Severity: Minor
                        Found in src/Phug/Formatter/Formatter.php - About 1 hr to fix

                          Method addModule has 39 lines of code (exceeds 25 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 1 hr to fix

                            Method initDebugOptions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function initDebugOptions(Renderer $profilerContainer)
                                {
                                    $profilerContainer->setOptionsDefaults([
                                        'memory_limit'       => $profilerContainer->getOption('debug') ? 0x3200000 : -1, // 50MB by default in debug
                                        'execution_max_time' => $profilerContainer->getOption('debug') ? 30000 : -1, // 30s by default in debug
                            Severity: Minor
                            Found in src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language