Showing 213 of 213 total issues
Avoid using static access to class '\CommerceGuys\Addressing\AddressFormat\AddressFormatHelper' in method 'preSubmit'. Open
foreach (AddressFormatHelper::getGroupedFields($addressFormat->getFormat(), $this->getFieldOverrides($form)) as $line_index => $line_fields) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method preSetData() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function preSetData(FormEvent $event): void
{
/** @var AddressEmbeddable $address */
$address = $event->getData();
$form = $event->getForm();
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method preSubmit() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public function preSubmit(FormEvent $event): void
{
$data = $event->getData();
if (!is_array($data) || !array_key_exists('countryCode', $data)) {
return;
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Line exceeds 120 characters; contains 125 characters Open
method_exists(TreeBuilder::class, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root(self::ROOT_NODE);
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
new TwigFunction('address_plain', [$this, 'addressPlain'], ['is_safe' => ['html'], 'needs_environment' => true]),
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
foreach (AddressFormatHelper::getGroupedFields($addressFormat->getFormat(), $this->getFieldOverrides($form)) as $line_index => $line_fields) {
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
new TwigFunction('address_inline', [$this, 'addressInline'], ['is_safe' => ['html'], 'needs_environment' => true]),
- Exclude checks
Line exceeds 120 characters; contains 146 characters Open
// When upgrading the min requirements to Symfony 5.1, use https://symfony.com/doc/current/reference/forms/types/choice.html#choice-filter
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
foreach (AddressFormatHelper::getGroupedFields($addressFormat->getFormat(), $fieldOverrides) as $line_index => $line_fields) {
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$parents[] = $index ? $original_values[$subdivision_fields[$index - 1]] : $addressEmbeddable->getCountryCode();
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
'help' => 'This field is used to search an address on Google and fill it out below. This could override other values!',
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$parents[] = $index ? $original_values[$subdivision_fields[$index - 1]] : $addressEmbeddable->getCountryCode();
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
new TwigFunction('address_default', [$this, 'addressDefault'], ['is_safe' => ['html'], 'needs_environment' => true]),
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$property_mapping = [
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
AddressField::POSTAL_CODE => 'postal_code',
- Exclude checks
Expected 1 space after closing brace; newline found Open
}
- Exclude checks
Expected 1 space after closing brace; newline found Open
}
- Exclude checks
Opening brace should be on a new line Open
public static function getPropertyName($field) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function __construct($options = null, $fieldOverrides = [])
- Exclude checks