railpage/railpagecore

View on GitHub
lib/Images/Provider/FiveHundredPx.php

Summary

Maintainability
B
6 hrs
Test Coverage

Avoid using undefined variables such as '$params' which will lead to PHP notices.
Open

        return $this->execute("photos/" . $id, $params); 
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$params' which will lead to PHP notices.
Open

        $params['image_size'] = "1,2,3,4,5,20,21,30,100,200,440,600,1080,1600,2048";
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid assigning values to variables in if clauses and the like (line '352', column '14').
Open

    private function normaliseSize($size) {
        
        $size['source'] = $size['https_url']; 
        
        $key = sprintf("%s:image.size;image=%s", self::PROVIDER_NAME, $size['source']); 
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php by phpmd

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

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

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

        $data = $this->getImage($photoId); 
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.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

Avoid unused parameters such as '$force'.
Open

    public function getImage($id, $force = 0) {
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid unused parameters such as '$itemsPerPage'.
Open

    public function getImages($page, $itemsPerPage) {
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid unused parameters such as '$page'.
Open

    public function getImages($page, $itemsPerPage) {
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid unused private fields such as '$oauth_consumer_secret'.
Open

    private $oauth_consumer_secret;
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php by phpmd

UnusedPrivateField

Since: 0.2

Detects when a private field is declared and/or assigned a value, but not used.

Example

class Something
{
    private static $FOO = 2; // Unused
    private $i = 5; // Unused
    private $j = 6;
    public function addOne()
    {
        return $this->j++;
    }
}

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

Avoid unused private fields such as '$photo'.
Open

    private $photo;
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php by phpmd

UnusedPrivateField

Since: 0.2

Detects when a private field is declared and/or assigned a value, but not used.

Example

class Something
{
    private static $FOO = 2; // Unused
    private $i = 5; // Unused
    private $j = 6;
    public function addOne()
    {
        return $this->j++;
    }
}

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

Avoid unused parameters such as '$imageObject'.
Open

    public function deleteImage(Image $imageObject) {
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid unused parameters such as '$imageObject'.
Open

    public function setImage(Image $imageObject) {
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid unused parameters such as '$imageObject'.
Open

    public function getImageContext(Image $imageObject) {
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid unused private methods such as 'configureOAuth'.
Open

    private function configureOAuth() {
        
    }
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php by phpmd

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        if ($response->getStatusCode() != 200) {
            throw new Exception(sprintf("An unexpected HTTP response code of %s was returned from %s", $response->getStatusCode(), self::PROVIDER_NAME));
        }
Severity: Major
Found in lib/Images/Provider/FiveHundredPx.php and 1 other location - About 1 hr to fix
lib/Images/Provider/Flickr.php on lines 450..452

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 41.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    public function setOptions($options) {
        
        foreach ($options as $key => $val) {
            
            $this->$key = $val;
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php and 1 other location - About 1 hr to fix
lib/Images/Provider/Flickr.php on lines 194..202

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

            $params = [
                "oauth_consumer_key" => "X9hfaNi3y6uJsVjOEz6Ld4lQIY1T8AqpR4mYJvYr",
                "oauth_consumer_secret" => "48ElAgTOSn1lYon4Phs8A1zjXpmy7jCTU4xa0t2o",
                "javascript_sdk_key" => "33339f35f4f5aad73b6380ce54a56cf0e464e076",
                "callback_url" => "http://www.railpage.com.au/endpoint/500px"
Severity: Major
Found in lib/Images/Provider/FiveHundredPx.php and 2 other locations - About 55 mins to fix
lib/Images/Competition.php on lines 182..187
lib/Images/Provider/Flickr.php on lines 156..161

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        $key = sprintf("%s:image.size;image=%s", self::PROVIDER_NAME, $size['source']); 
Severity: Major
Found in lib/Images/Provider/FiveHundredPx.php and 2 other locations - About 50 mins to fix
lib/Gallery/Utility/CreateSizes.php on lines 42..42
lib/Gallery/Utility/CreateSizes.php on lines 145..145

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 27.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            "uploaded" => DateTime::CreateFromFormat(self::PROVIDER_TIMESTAMP_FORMAT, $result['created_at'])
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php and 1 other location - About 35 mins to fix
lib/Images/Provider/FiveHundredPx.php on lines 329..329

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 22.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            "taken" => DateTime::CreateFromFormat(self::PROVIDER_TIMESTAMP_FORMAT, $result['taken_at']),
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.php and 1 other location - About 35 mins to fix
lib/Images/Provider/FiveHundredPx.php on lines 330..330

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 22.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

        $result['location'] = [ 
            "latitude" => $result['latitude'],
            "longitude" => $result['longitude']
        ];
Severity: Major
Found in lib/Images/Provider/FiveHundredPx.php and 3 other locations - About 30 mins to fix
lib/Images/Exif.php on lines 294..294
lib/Images/Utility/Geoplace.php on lines 111..114
lib/Locos/Utility/LocomotiveUtility.php on lines 445..448

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 21.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

            $url = sprintf("%s?%s", $url, $params);
Severity: Major
Found in lib/Images/Provider/FiveHundredPx.php and 5 other locations - About 30 mins to fix
lib/Images/Images.php on lines 104..104
lib/Images/Utility/Finder.php on lines 230..230
lib/Locations/Factory.php on lines 88..88
lib/Place.php on lines 781..781
lib/PlaceUtility.php on lines 329..329

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 20.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    private $oauth_consumer_secret;
Severity: Minor
Found in lib/Images/Provider/FiveHundredPx.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

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

Blank line found at start of control structure
Open

        if (!$result = $this->Memcached->fetch($key)) {

Blank line found at start of control structure
Open

        foreach ($options as $key => $val) {

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

Blank line found at end of control structure
Open

            

Line indented incorrectly; expected at least 16 spaces, found 12
Open

            $this->$key = $val; 

Line indented incorrectly; expected 12 spaces, found 8
Open

        }

Line indented incorrectly; expected at least 12 spaces, found 8
Open

        $this->Client = new Client;

Line indented incorrectly; expected 12 spaces, found 8
Open

        foreach ($params as $key => $val) {

There are no issues that match your filters.

Category
Status