owncloud/core

View on GitHub
lib/public/AppFramework/Db/Mapper.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method findOneQuery has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function findOneQuery($sql, array $params=[], $limit=null, $offset=null) {
        if ($sql instanceof IQueryBuilder) {
            $stmt = $sql->execute();
        } else {
            $stmt = $this->execute($sql, $params, $limit, $offset);
Severity: Minor
Found in lib/public/AppFramework/Db/Mapper.php - About 1 hr to fix

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

        public function update(Entity $entity) {
            // if entity wasn't changed it makes no sense to run a db query
            $properties = $entity->getUpdatedFields();
            if (\count($properties) === 0) {
                return $entity;
    Severity: Minor
    Found in lib/public/AppFramework/Db/Mapper.php - About 1 hr to fix

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

          protected function execute($sql, array $params=[], $limit=null, $offset=null) {
              if ($this->db instanceof IDb) {
                  $query = $this->db->prepareQuery($sql, $limit, $offset);
              } else {
                  $query = $this->db->prepare($sql, $limit, $offset);
      Severity: Minor
      Found in lib/public/AppFramework/Db/Mapper.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 buildDebugMessage has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private function buildDebugMessage($msg, $sql, array $params=[], $limit=null, $offset=null) {
      Severity: Minor
      Found in lib/public/AppFramework/Db/Mapper.php - About 35 mins to fix

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

            protected function findOneQuery($sql, array $params=[], $limit=null, $offset=null) {
                if ($sql instanceof IQueryBuilder) {
                    $stmt = $sql->execute();
                } else {
                    $stmt = $this->execute($sql, $params, $limit, $offset);
        Severity: Minor
        Found in lib/public/AppFramework/Db/Mapper.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

        There are no issues that match your filters.

        Category
        Status