mheinzerling/php-meta

View on GitHub

Showing 29 of 29 total issues

The class ClassWriter has 12 public methods. Consider refactoring ClassWriter to keep number of public methods under 10.
Open

class ClassWriter
{
    const USEBLOCK = "__USE__";
    /**
     * @var string
Severity: Minor
Found in src/writer/ClassWriter.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

The class MethodWriter has 16 public methods. Consider refactoring MethodWriter to keep number of public methods under 10.
Open

class MethodWriter
{
    const NODEFAULT = "__NODEFAULT__";
    /**
     * @var string
Severity: Minor
Found in src/writer/MethodWriter.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

The class FieldWriter has 13 public methods. Consider refactoring FieldWriter to keep number of public methods under 10.
Open

class FieldWriter
{
    /**
     * @var ClassWriter
     */
Severity: Minor
Found in src/writer/FieldWriter.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

Function write has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function write(): string
    {
        $result = $this->line("<?php");
        $result .= $this->line("declare(strict_types = 1);");
        $result .= $this->line("");
Severity: Minor
Found in src/writer/ClassWriter.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 write has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function write(): string
    {
        $result = $this->line("<?php");
        $result .= $this->line("declare(strict_types = 1);");
        $result .= $this->line("");
Severity: Minor
Found in src/writer/ClassWriter.php - About 1 hr to fix

    Function toValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function toValue(PHPType $type, $value): string
        {
            if ($type instanceof PrimitivePHPType) {
                if ($value === null) return 'null';
                if ($type->isInt()) return (string)$value;
    Severity: Minor
    Found in src/writer/TypeConverter.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

    Avoid variables with short names like $a. Configured minimum length is 3.
    Open

            uksort($this->use, function ($a, $b) {
    Severity: Minor
    Found in src/writer/ClassWriter.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $b. Configured minimum length is 3.
    Open

            uksort($this->use, function ($a, $b) {
    Severity: Minor
    Found in src/writer/ClassWriter.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Missing class import via use statement (line '28', column '23').
    Open

                throw new \Exception("Unhandled type " . get_class($type));
    Severity: Minor
    Found in src/writer/TypeConverter.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '43', column '23').
    Open

                throw new \Exception("Unhandled type " . get_class($type));
    Severity: Minor
    Found in src/writer/TypeConverter.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '58', column '23').
    Open

                throw new \Exception("Unsupported for objects " . $type->getClass()->fullyQualified());
    Severity: Minor
    Found in src/writer/TypeConverter.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    The method static has a boolean flag argument $static, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function static (bool $static = true): MethodWriter
    Severity: Minor
    Found in src/writer/MethodWriter.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    Missing class import via use statement (line '20', column '23').
    Open

                throw new \Exception("Fully qualified namespace required, starting with \\. Got: >$fullyQualifiedName<");
    Severity: Minor
    Found in src/language/ANamespace.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    The method static has a boolean flag argument $static, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function static (bool $static = true): FieldWriter
    Severity: Minor
    Found in src/writer/FieldWriter.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    Missing class import via use statement (line '17', column '19').
    Open

            throw new \Exception("Unhandled type " . get_class($type));
    Severity: Minor
    Found in src/writer/TypeConverter.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '60', column '19').
    Open

            throw new \Exception("Unhandled type " . get_class($type));
    Severity: Minor
    Found in src/writer/TypeConverter.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Avoid too many return statements within this method.
    Open

                if ($value === null) return 'null';
    Severity: Major
    Found in src/writer/TypeConverter.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return 0;
      Severity: Major
      Found in src/writer/ClassWriter.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return $this;
        Severity: Major
        Found in src/writer/ClassWriter.php - About 30 mins to fix

          The method final has a boolean flag argument $final, which is a certain sign of a Single Responsibility Principle violation.
          Open

              public function final(bool $final = true): ClassWriter
          Severity: Minor
          Found in src/writer/ClassWriter.php by phpmd

          BooleanArgumentFlag

          Since: 1.4.0

          A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

          Example

          class Foo {
              public function bar($flag = true) {
              }
          }

          Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

          Severity
          Category
          Status
          Source
          Language