bwinkers/nugget

View on GitHub

Showing 134 of 134 total issues

Argument 1 (arr1) is string but \array_merge() takes array
Open

    $property = array_merge($property, $resolved);
Severity: Minor
Found in src/bin/readPropertiesFromGoogle.php by phan

Parameter $property has undeclared type \type
Open

function propertyExists($property)
Severity: Minor
Found in src/bin/readPropertiesFromGoogle.php by phan

Reference to undeclared property \Activerules\Nugget\Nugget->schemaBuilder
Open

        $nugget->schemaBuilder->mergeRequired($parentDef, $schemaDef);
Severity: Minor
Found in src/bin/schemaFromObject.php by phan

Call to method getFilename on non-class type string
Open

        $name = $fileInfo->getFilename();
Severity: Critical
Found in src/Filesys.php by phan

Call to undeclared method \Activerules\Nugget\GClient::setScopes
Open

            $this->setScopes($scopes);
Severity: Critical
Found in src/GClient.php by phan

Reference to undeclared property \Activerules\Nugget\GSheet->spreadsheets_values
Open

            return $this->spreadsheets_values->get($spreadsheetID, $range);
Severity: Minor
Found in src/GSheet.php by phan

Call to method fails from undeclared class \Activerules\JsonGuard\Validator
Open

        return $validator->fails() ? false : true;
Severity: Critical
Found in src/Schema.php by phan

Possibly zero references to use statement for classlike/namespace NuggetException (\Activerules\Nugget\Exception\NuggetException)
Open

use Activerules\Nugget\Exception\NuggetException;
Severity: Minor
Found in src/GSheetReader.php by phan

Argument 1 (filename) is \Activerules\Nugget\type but \file_get_contents() takes string
Open

        $file = file_get_contents($url);
Severity: Minor
Found in src/GSheetReader.php by phan

Reference to constant SPREADSHEETS_READONLY from undeclared class \Google_Service_Sheets
Open

define('SCOPES', implode(' ', array(Google_Service_Sheets::SPREADSHEETS_READONLY)));
Severity: Critical
Found in src/bin/readPropertiesFromGoogle.php by phan

Either remove or fill this block of code.
Open

        } catch (NuggetException $ex) {
            
        }
Severity: Major
Found in src/SClient.php by sonar-php

Most of the time a block of code is empty when a piece of code is really missing. So such empty block must be either filled or removed.

Noncompliant Code Example

for ($i = 0; $i < 42; $i++){}  // Empty on purpose or missing piece of code ?

Exceptions

When a block contains a comment, this block is not considered to be empty.

Class extends undeclared class \Google_Service_Sheets
Open

class GSheet extends Google_Service_Sheets
Severity: Critical
Found in src/GSheet.php by phan

Argument 1 (property) is array{description:mixed,types:array<int>,name:mixed}</int> but \processProperty() takes string defined at /code/src/bin/readPropertiesFromGoogle.php:71
Open

        processProperty($property);
Severity: Minor
Found in src/bin/readPropertiesFromGoogle.php by phan

When fetching an array index from a value of type string, found an array index of type 'name', but expected the index to be of type int
Open

    $propertyName = $property['name'];
Severity: Minor
Found in src/bin/readPropertiesFromGoogle.php by phan

Returning type bool but propertyExists() is declared to return \type
Open

    return file_exists(PROPERTYDIR + DIRECTORY_SEPARATOR + $property['name'] + '.json');
Severity: Minor
Found in src/bin/readPropertiesFromGoogle.php by phan

Argument 1 (refString) is object but \loadRef() takes string defined at /code/src/bin/schemaFromObject.php:358
Open

            loadRef($def, $defs);
Severity: Minor
Found in src/bin/schemaFromObject.php by phan

Define a constant instead of duplicating this literal "comment" 7 times.
Open

        'comment' => 'signed 32 bits'
Severity: Critical
Found in src/lookup/nuggetTypes.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Possibly zero references to use statement for classlike/namespace NuggetException (\Activerules\Nugget\Exception\NuggetException)
Open

use Activerules\Nugget\Exception\NuggetException;
Severity: Minor
Found in src/Filesys.php by phan

Reference to undeclared class \Google_Client
Open

        parent::__construct($config);
Severity: Critical
Found in src/GClient.php by phan

Returning type false|string but loadGsheetCSV() is declared to return object
Open

        return $file;
Severity: Minor
Found in src/GSheetReader.php by phan
Severity
Category
Status
Source
Language