Showing 48 of 48 total issues
File AbstractFormat.php
has 806 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Phug\Formatter;
use Phug\Formatter;
File XmlFormat.php
has 448 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Phug\Formatter\Format;
use Closure;
AbstractFormat
has 40 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class AbstractFormat implements FormatInterface, OptionInterface
{
use HandleVariable;
use OptionTrait;
use PatternTrait;
Method formatMixinCallElement
has 117 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function formatMixinCallElement(MixinCallElement $mixinCall)
{
$hasBlock = $mixinCall->hasChildren();
$children = new PhpUnwrap($this->formatElementChildren($mixinCall), $this->formatter);
$mixinName = $mixinCall->getName();
File Formatter.php
has 342 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Phug;
// Elements
Function getSourceLine
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
private function getSourceLine($error)
{
$previous = null;
$line = null;
- Read upRead up
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 formatMixinElement
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function formatMixinElement(MixinElement $mixin)
{
$mixinName = $mixin->getName();
$name = is_string($mixinName)
? var_export($mixinName, true)
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,
Formatter
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class Formatter implements ModuleContainerInterface
{
use LevelTrait;
use ModuleContainerTrait;
Method yieldAssignmentElement
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function yieldAssignmentElement(AssignmentElement $element)
{
foreach ($this->getOption('assignment_handlers') as $handler) {
$iterator = $handler($element) ?: [];
XmlFormat
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class XmlFormat extends AbstractFormat
{
use AssignmentHelpersTrait;
const DOCTYPE = '<?xml version="1.0" encoding="utf-8" ?>';
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;
- Read upRead up
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 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(Formatter $formatter = null)
{
$this->setOptionsRecursive([
'white_space_sensitive_tags' => [
'pre',
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');
- Read upRead up
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 => [
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,
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');
Method getSourceLine
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getSourceLine($error)
{
$previous = null;
$line = null;
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;
Function hasNonStaticAttributes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function hasNonStaticAttributes(MarkupInterface $element)
{
if ($element instanceof MarkupElement || $element instanceof MixinCallElement) {
foreach ($element->getAttributes() as $attribute) {
if ($attribute->hasStaticMember('value')) {
- Read upRead up
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"