tawfekov/ZF2EntityAudit

View on GitHub

Showing 20 of 20 total issues

Function createEntity has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    private function createEntity($className, array $data)
    {
        $class = $this->em->getClassMetadata($className);
        $entity = $class->newInstance();

Severity: Minor
Found in src/ZF2EntityAudit/Audit/Reader.php - About 4 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

Function find has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function find($className, $id, $revision)
    {
        if (!$this->metadataFactory->isAudited($className)) {
            throw Exception::notAudited($className);
        }
Severity: Minor
Found in src/ZF2EntityAudit/Audit/Reader.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

Configuration has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class Configuration
{
    private $prefix = '';
    private $suffix = '_audit';
    private $revisionFieldName = 'rev';
Severity: Minor
Found in src/ZF2EntityAudit/Audit/Configuration.php - About 2 hrs to fix

    File Reader.php has 271 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    namespace ZF2EntityAudit\Audit;
    
    use Doctrine\DBAL\Types\Type;
    use Doctrine\ORM\EntityManager;
    Severity: Minor
    Found in src/ZF2EntityAudit/Audit/Reader.php - About 2 hrs to fix

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

          public function findEntitesChangedAtRevision($revision)
          {
              $auditedEntities = $this->metadataFactory->getAllClassNames();
      
              $changedEntities = array();
      Severity: Minor
      Found in src/ZF2EntityAudit/Audit/Reader.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

      Function saveRevisionEntityData has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function saveRevisionEntityData($class, $entityData, $revType)
          {
              $params = array($this->getRevisionId(), $revType);
              $types = array(\PDO::PARAM_INT, \PDO::PARAM_STR);
      
      
      Severity: Minor
      Found in src/ZF2EntityAudit/EventListener/LogRevisionsListener.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 find has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function find($className, $id, $revision)
          {
              if (!$this->metadataFactory->isAudited($className)) {
                  throw Exception::notAudited($className);
              }
      Severity: Minor
      Found in src/ZF2EntityAudit/Audit/Reader.php - About 1 hr to fix

        Method updateAction has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function updateAction()
            {
                echo "- before starting : 1- please take a backup \n";
                echo "                    2- update the all `anonymous` in the revisions table to some exsited user \n";
                echo "- cancel this command and update it then restart it again \n";
        Severity: Minor
        Found in src/ZF2EntityAudit/Controller/ConsoleController.php - About 1 hr to fix

          Function findRevisions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function findRevisions($className, $id)
              {
                  if (!$this->metadataFactory->isAudited($className)) {
                      throw Exception::notAudited($className);
                  }
          Severity: Minor
          Found in src/ZF2EntityAudit/Audit/Reader.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 getInsertRevisionSQL has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getInsertRevisionSQL($class)
              {
                  if (!isset($this->insertRevisionSQL[$class->name])) {
                      $placeholders = array('?', '?');
                      $tableName    = $this->config->getTablePrefix() . $class->table['name'] . $this->config->getTableSuffix();
          Severity: Minor
          Found in src/ZF2EntityAudit/EventListener/LogRevisionsListener.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 createEntity has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function createEntity($className, array $data)
              {
                  $class = $this->em->getClassMetadata($className);
                  $entity = $class->newInstance();
          
          
          Severity: Minor
          Found in src/ZF2EntityAudit/Audit/Reader.php - About 1 hr to fix

            Method getServiceConfig has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getServiceConfig()
                {
                    return array(
                        'factories' => array(
                            'auditConfig' => function($sm){
            Severity: Minor
            Found in Module.php - About 1 hr to fix

              Method findRevisions has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function findRevisions($className, $id)
                  {
                      if (!$this->metadataFactory->isAudited($className)) {
                          throw Exception::notAudited($className);
                      }
              Severity: Minor
              Found in src/ZF2EntityAudit/Audit/Reader.php - About 1 hr to fix

                Method findEntitesChangedAtRevision has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function findEntitesChangedAtRevision($revision)
                    {
                        $auditedEntities = $this->metadataFactory->getAllClassNames();
                
                        $changedEntities = array();
                Severity: Minor
                Found in src/ZF2EntityAudit/Audit/Reader.php - About 1 hr to fix

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

                      public function createInitialRevisionsAction()
                      {
                          $request = $this->getRequest();
                          if (!$request instanceof ConsoleRequest) {
                              throw new RuntimeException('You can only use this action from a console!');
                  Severity: Minor
                  Found in src/ZF2EntityAudit/Controller/ConsoleController.php - About 1 hr to fix

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

                        public function getViewHelperConfig()
                        {
                             return array(
                                'factories' => array(
                                    'DateTimeFormatter' => function($sm) {
                    Severity: Minor
                    Found in Module.php - About 1 hr to fix

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

                          public function createInitialRevisionsAction()
                          {
                              $request = $this->getRequest();
                              if (!$request instanceof ConsoleRequest) {
                                  throw new RuntimeException('You can only use this action from a console!');
                      Severity: Minor
                      Found in src/ZF2EntityAudit/Controller/ConsoleController.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($rev, $timestamp,  $user , $note = '' , $ipaddress = '')
                      Severity: Minor
                      Found in src/ZF2EntityAudit/Entity/Revision.php - About 35 mins to fix

                        Method revertBack has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            public function revertBack(EntityManager $em,$className,$id,$oldRevId,$newRevId)
                        Severity: Minor
                        Found in src/ZF2EntityAudit/Audit/Manager.php - About 35 mins to fix

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

                              public function diff(array $old, array $new)
                              {
                                  $maxlen = 0;
                                  foreach ($old as $oindex => $ovalue) {
                                      $nkeys = array_keys($new, $ovalue);
                          Severity: Minor
                          Found in src/ZF2EntityAudit/Utils/SimpleDiff.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

                          Severity
                          Category
                          Status
                          Source
                          Language