slimphp-api/slim-api

View on GitHub

Showing 7 of 7 total issues

Function create has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function create($path, $name, $structure = false)
    {
        if (false === $structure) {
            $structure = $this->structure;
        }
Severity: Minor
Found in src/Skeleton/SkeletonService.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 configure has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function configure()
    {
        $this
            ->setName('generate')
            ->setAliases(['g'])
Severity: Minor
Found in src/Command/GenerateCommand.php - About 1 hr to fix

    Method addRoute has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function addRoute($method)
        {
            switch ($method) {
                case 'index':
                    $methodMap          = ['GET'];
    Severity: Minor
    Found in src/Service/RouteService.php - About 1 hr to fix

      Method execute has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function execute(InputInterface $input, OutputInterface $output)
          {
              $type = $input->getArgument('type');
              if (!in_array($type, ['scaffold', 'controller', 'model', 'migration'])) {
                  throw new Exception('Invalid type.');
      Severity: Minor
      Found in src/Command/GenerateCommand.php - About 1 hr to fix

        Function execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function execute(InputInterface $input, OutputInterface $output)
            {
                $name    = ucfirst($input->getArgument('name'));
                $pattern = '/^[A-Z][a-zA-Z0-9]*$/';
                if (1 !== preg_match($pattern, $name)) {
        Severity: Minor
        Found in src/Command/InitCommand.php - About 45 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

        Function addRoute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function addRoute($method)
            {
                switch ($method) {
                    case 'index':
                        $methodMap          = ['GET'];
        Severity: Minor
        Found in src/Service/RouteService.php - About 35 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

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

            protected function execute(InputInterface $input, OutputInterface $output)
            {
                $type = $input->getArgument('type');
                if (!in_array($type, ['scaffold', 'controller', 'model', 'migration'])) {
                    throw new Exception('Invalid type.');
        Severity: Minor
        Found in src/Command/GenerateCommand.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