newscoop/plugin-NewscoopPaywallBundle

View on GitHub
Controller/AdminController.php

Summary

Maintainability
D
2 days
Test Coverage

File AdminController.php has 325 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * @author Rafał Muszyński <rafal.muszynski@sourcefabric.org>
 * @copyright 2013 Sourcefabric o.p.s.
Severity: Minor
Found in Controller/AdminController.php - About 3 hrs to fix

    Function adminAction has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public function adminAction(Request $request, $id = null)
        {
            $em = $this->getDoctrine()->getManager();
            if ($id) {
                $this->hasPermission(Permissions::SUBSCRIPTIONS_MANAGE);
    Severity: Minor
    Found in Controller/AdminController.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 durationAction has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function durationAction(Request $request, $id = null)
        {
            $em = $this->getDoctrine()->getManager();
            $duration = new Duration();
            $form = $this->createForm(new DurationType(), $duration);
    Severity: Major
    Found in Controller/AdminController.php - About 2 hrs to fix

      Method adminAction has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function adminAction(Request $request, $id = null)
          {
              $em = $this->getDoctrine()->getManager();
              if ($id) {
                  $this->hasPermission(Permissions::SUBSCRIPTIONS_MANAGE);
      Severity: Major
      Found in Controller/AdminController.php - About 2 hrs to fix

        Function step2Action has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function step2Action(Request $request, $id = null)
            {
                $em = $this->getDoctrine()->getManager();
                $create = false;
                if ($id) {
        Severity: Minor
        Found in Controller/AdminController.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 step2Action has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function step2Action(Request $request, $id = null)
            {
                $em = $this->getDoctrine()->getManager();
                $create = false;
                if ($id) {
        Severity: Minor
        Found in Controller/AdminController.php - About 1 hr to fix

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

              public function durationAction(Request $request, $id = null)
              {
                  $em = $this->getDoctrine()->getManager();
                  $duration = new Duration();
                  $form = $this->createForm(new DurationType(), $duration);
          Severity: Minor
          Found in Controller/AdminController.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

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

              private function getErrorMessages(\Symfony\Component\Form\Form $form)
              {
                  $errors = array();
                  if (count($form) > 0) {
                      foreach ($form->all() as $child) {
          Severity: Minor
          Found in Controller/AdminController.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

          Avoid too many return statements within this method.
          Open

                  return array(
                      'form' => $form->createView(),
                      'formSpecification' => $formSpecification->createView(),
                      'subscription_id' => $subscription->getId(),
                      'ranges' => $subscription->getRanges()->toArray(),
          Severity: Major
          Found in Controller/AdminController.php - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status