onema/classyfile

View on GitHub

Showing 5 of 5 total issues

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

    protected function configure()
    {
        $this
            ->setName('convert')
            ->setDescription('Opens a directory and reads every PHP file, it takes the classes in the file and generates one file per class.')
Severity: Major
Found in src/Console/Command/GenerateClassesFromFileCommand.php - About 2 hrs to fix

    Method testClassToFileConversionMocked has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function testClassToFileConversionMocked()
        {
            $mockAdapter = $this->getMockBuilder('\League\Flysystem\Adapter\Local')
                ->disableOriginalConstructor()
                ->setMethods(['has', 'createDir', 'update', 'write'])
    Severity: Minor
    Found in tests/ClassyFileTest.php - About 1 hr to fix

      Function traverseStatements has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function traverseStatements($statements, $namespaceString = '')
          {
              $uses = '';
              $code = [];
      
      
      Severity: Minor
      Found in src/ClassyFile.php - About 55 mins 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 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function __construct(Stmt $statement, $fileLocation = null, $namespace = null, $uses = null, $code = null)
      Severity: Minor
      Found in src/Event/GetClassEvent.php - About 35 mins to fix

        Function onSetClassUpdateConstants has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function onSetClassUpdateConstants(ClassyFileEvent $event)
            {
                $statements = $event->getStatements();
                if ($statements instanceof Class_) {
                    $count = count($statements->stmts);
        Severity: Minor
        Found in src/Plugin/ConstantNamesToUpper.php - About 25 mins 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

        Severity
        Category
        Status
        Source
        Language