squirrelphp/entities

View on GitHub

Showing 53 of 59 total issues

RepositoryReadOnly has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class RepositoryReadOnly implements RepositoryReadOnlyInterface
{
    protected array $tableToObjectFields = [];
    protected array $objectToTableFields = [];
    protected array $objectTypes = [];
Severity: Minor
Found in src/RepositoryReadOnly.php - About 2 hrs to fix

    Method preprocessWhere has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function preprocessWhere(array $whereOptions, array $objectToTableFields): array
        {
            // List of finished WHERE expressions, to be imploded with ANDs
            $whereProcessed = [];
    
    
    Severity: Major
    Found in src/MultiRepositoryReadOnly.php - About 2 hrs to fix

      Method __invoke has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __invoke(): array
          {
              /** @var list<string> $logRepositories */
              $logRepositories = [];
              /** @var list<string> $logConflicts */
      Severity: Major
      Found in src/Generate/RepositoriesGenerateCommand.php - About 2 hrs to fix

        Method buildSelectQueryStructured has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function buildSelectQueryStructured(array $query): array
            {
                // Process options and make sure all values are valid
                [
                    $sanitizedOptions,
        Severity: Minor
        Found in src/MultiRepositoryReadOnly.php - About 1 hr to fix

          Method preprocessGroup has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function preprocessGroup(array $groupByOptions, array $objectToTableFields): array
              {
                  // List of finished WHERE expressions, to be imploded with ANDs
                  $groupByProcessed = [];
          
          
          Severity: Minor
          Found in src/MultiRepositoryReadOnly.php - About 1 hr to fix

            Method process has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function process(object|string $class): ?RepositoryConfigInterface
                {
                    // Get class reflection data
                    $reflectionClass = new \ReflectionClass($class);
            
            
            Severity: Minor
            Found in src/Attribute/EntityProcessor.php - About 1 hr to fix

              Function preprocessChanges has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function preprocessChanges(array $changes): array
                  {
                      // Separate field SQL and field values
                      $changesProcessed = [];
              
              
              Severity: Minor
              Found in src/RepositoryWriteable.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 preprocessWhere has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function preprocessWhere(array $where): array
                  {
                      // SQL restrictions as an array
                      $whereProcessed = [];
              
              
              Severity: Minor
              Found in src/RepositoryReadOnly.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 castOneTableVariable has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function castOneTableVariable(mixed $value, ?string $fieldName = null, bool $isChange = false): int|float|string|LargeObject|null
                  {
                      // Only scalar values and null are allowed
                      if (!\is_null($value) && !\is_scalar($value)) {
                          throw Debug::createException(
              Severity: Minor
              Found in src/RepositoryReadOnly.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 preprocessOrder has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function preprocessOrder(array $orderOptions, array $objectToTableFields): array
                  {
                      // List of finished WHERE expressions, to be imploded with ANDs
                      $orderProcessed = [];
              
              
              Severity: Minor
              Found in src/MultiRepositoryReadOnly.php - About 1 hr to fix

                Method processSelectResult has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function processSelectResult(
                        array $entry,
                        array $selectTypes,
                        array $selectTypesNullable,
                    ): array {
                Severity: Minor
                Found in src/MultiRepositoryReadOnly.php - About 1 hr to fix

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

                      private function prepareSelectQueryForLowerLayer(array $query): array
                      {
                          // Set the table variable for SQL component
                          $query['table'] = $this->config->getTableName();
                  
                  
                  Severity: Minor
                  Found in src/RepositoryReadOnly.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 preprocessOrder has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function preprocessOrder(array $orderOptions): array
                      {
                          // Order SQL parts
                          $orderProcessed = [];
                  
                  
                  Severity: Minor
                  Found in src/RepositoryReadOnly.php - About 1 hr to fix

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

                        public function insertOrUpdate(array $fields, array $indexFields = [], ?array $updateFields = null): void
                        {
                            // Fields after conversion to table notation
                            $actualIndexFields = [];
                    
                    
                    Severity: Minor
                    Found in src/RepositoryWriteable.php - About 1 hr to fix

                      Method prepareSelectQueryForLowerLayer has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function prepareSelectQueryForLowerLayer(array $query): array
                          {
                              // Set the table variable for SQL component
                              $query['table'] = $this->config->getTableName();
                      
                      
                      Severity: Minor
                      Found in src/RepositoryReadOnly.php - About 1 hr to fix

                        Method preprocessWhere has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function preprocessWhere(array $where): array
                            {
                                // SQL restrictions as an array
                                $whereProcessed = [];
                        
                        
                        Severity: Minor
                        Found in src/RepositoryReadOnly.php - About 1 hr to fix

                          Method preprocessChanges has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function preprocessChanges(array $changes): array
                              {
                                  // Separate field SQL and field values
                                  $changesProcessed = [];
                          
                          
                          Severity: Minor
                          Found in src/RepositoryWriteable.php - About 1 hr to fix

                            Method insert has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function insert(array $fields, bool $returnInsertId = false): ?string
                                {
                                    // Make sure we have an autoincrement field if one is requested
                                    if ($returnInsertId === true && \strlen($this->config->getAutoincrementField()) === 0) {
                                        throw Debug::createException(
                            Severity: Minor
                            Found in src/RepositoryWriteable.php - About 1 hr to fix

                              Method validateQueryOptions has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  protected function validateQueryOptions(array $validOptions, array $options): array
                                  {
                                      // One field shortcut - convert to fields array
                                      if (isset($validOptions['fields']) && isset($options['field']) && !isset($options['fields'])) {
                                          $options['fields'] = [$options['field']];
                              Severity: Minor
                              Found in src/RepositoryReadOnly.php - About 1 hr to fix

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

                                    protected function validateQueryOptions(array $validOptions, array $options): array
                                    {
                                        // One field shortcut - convert to fields array
                                        if (isset($validOptions['fields']) && isset($options['field']) && !isset($options['fields'])) {
                                            $options['fields'] = [$options['field']];
                                Severity: Minor
                                Found in src/RepositoryReadOnly.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

                                Severity
                                Category
                                Status
                                Source
                                Language