bwinkers/nugget

View on GitHub
src/bin/schemaFromObject.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '275', column '19').
Open

    $nugget = new \Activerules\Nugget\Nugget();
Severity: Minor
Found in src/bin/schemaFromObject.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '38', column '18').
Open

    $files = new \DirectoryIterator($objectDir);
Severity: Minor
Found in src/bin/schemaFromObject.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '36', column '19').
Open

    $nugget = new \Activerules\Nugget\Nugget();
Severity: Minor
Found in src/bin/schemaFromObject.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '194', column '19').
Open

    $nugget = new \Activerules\Nugget\Nugget();
Severity: Minor
Found in src/bin/schemaFromObject.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Define a constant instead of duplicating this literal ".json" 4 times.
Open

    $objFile = realpath($schemaDir . '/' . $refSchemaName . '.json');
Severity: Critical
Found in src/bin/schemaFromObject.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.

Argument 3 (defs) is string but \resolvePropertyReference() takes array defined at /code/src/bin/schemaFromObject.php:309
Open

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

Argument 1 (schema) is false|string but \populateRef() takes object defined at /code/src/bin/schemaFromObject.php:68
Open

        populateRef($name, $defs);
Severity: Minor
Found in src/bin/schemaFromObject.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

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

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

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

Argument 2 (ref) is array but \populateRef() takes string defined at /code/src/bin/schemaFromObject.php:68
Open

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

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

            $props[$property] = $nugget->schemaBuilder->loadPropertyFile($propertyFile);
Severity: Minor
Found in src/bin/schemaFromObject.php by phan

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 34 and the first side effect is on line 2.
Open

<?php
Severity: Minor
Found in src/bin/schemaFromObject.php by phpcodesniffer

PHP keywords must be lowercase; expected "and" but found "AND"
Open

    if (isset($parentDef->extends) AND is_string($parentDef->extends)) {
Severity: Minor
Found in src/bin/schemaFromObject.php by phpcodesniffer

PHP keywords must be lowercase; expected "and" but found "AND"
Open

    if (isset($schemaDef->extends) AND is_string($schemaDef->extends)) {
Severity: Minor
Found in src/bin/schemaFromObject.php by phpcodesniffer

Whitespace found at end of line
Open

 * 
Severity: Minor
Found in src/bin/schemaFromObject.php by phpcodesniffer

Whitespace found at end of line
Open

 * 
Severity: Minor
Found in src/bin/schemaFromObject.php by phpcodesniffer

There are no issues that match your filters.

Category
Status