ibudasov/php7-iptc-manager

View on GitHub

Showing 12 of 12 total issues

Avoid excessively long variable names like $beginningOfTheBinaryString. Keep variable name length under 20.
Open

        $beginningOfTheBinaryString = \chr(0x1c)
Severity: Minor
Found in src/Domain/Binary.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $updatedBinaryFileContent. Keep variable name length under 20.
Open

        $updatedBinaryFileContent = $this->image->writeIptcTags($this->pathToFile, $binaryString);
Severity: Minor
Found in src/Manager.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Missing class import via use statement (line '150', column '23').
Open

            throw new \Exception('Can not write IPTC tags to file: '.$this->pathToFile);
Severity: Minor
Found in src/Manager.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 '165', column '23').
Open

            throw new \InvalidArgumentException(
Severity: Minor
Found in src/Manager.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 '177', column '23').
Open

            throw new \InvalidArgumentException('File not found');
Severity: Minor
Found in src/Manager.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 '85', column '27').
Open

                throw new \LogicException(
Severity: Minor
Found in src/Manager.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 '108', column '19').
Open

        throw new \InvalidArgumentException(
Severity: Minor
Found in src/Manager.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

Avoid unused local variables such as '$key'.
Open

        foreach ($this->tags as $key => $existingTag) {
Severity: Minor
Found in src/Manager.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Assigning string[] to property but \iBudasov\Iptc\Domain\Tag->value is string
Open

        $this->value = $valuesOfTag;
Severity: Minor
Found in src/Domain/Tag.php by phan

Define a constant instead of duplicating this literal "APP13" 3 times.
Open

        $foundTags = \iptcparse($imageInfo['APP13']);

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.

Define and throw a dedicated exception instead of using a generic one.
Open

            throw new \Exception('Can not write IPTC tags to file: '.$this->pathToFile);
Severity: Major
Found in src/Manager.php by sonar-php

If you throw a general exception type, such as ErrorException, RuntimeException, or Exception in a library or framework, it forces consumers to catch all exceptions, including unknown exceptions that they do not know how to handle.

Instead, either throw a subtype that already exists in the Standard PHP Library, or create your own type that derives from Exception.

Noncompliant Code Example

throw new Exception();  // Noncompliant

Compliant Solution

throw new InvalidArgumentException();
// or
throw new UnexpectedValueException();

See

Returning type string but getValues() is declared to return string[]
Open

        return $this->value;
Severity: Minor
Found in src/Domain/Tag.php by phan
Severity
Category
Status
Source
Language