railpage/railpagecore

View on GitHub
lib/Railcams/Footage.php

Summary

Maintainability
A
3 hrs
Test Coverage

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

        if (!$this->timeStamp instanceof DateTime) {
            $this->timeStamp = new DateTime;
        }
Severity: Major
Found in lib/Railcams/Footage.php and 13 other locations - About 50 mins to fix
lib/Content/Page.php on lines 172..174
lib/Downloads/Download.php on lines 285..287
lib/Gallery/Image.php on lines 177..179
lib/Gallery/Image.php on lines 326..328
lib/Glossary/Entry.php on lines 266..268
lib/Ideas/Idea.php on lines 252..254
lib/Images/Collection.php on lines 192..194
lib/Locations/Correction.php on lines 172..174
lib/Locos/Correction.php on lines 183..185
lib/News/Article.php on lines 778..780
lib/Notifications/Notification.php on lines 187..189
lib/Railcams/Camera.php on lines 363..365
lib/Warnings/Warning.php on lines 227..229

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 25 locations. Consider refactoring.
Open

    public function setCamera(Camera $cameraObject) {
        
        $this->cameraObject = $cameraObject; 
        
        return $this;
Severity: Major
Found in lib/Railcams/Footage.php and 24 other locations - About 40 mins to fix
lib/Feedback/Feedback.php on lines 52..56
lib/Gallery/Album.php on lines 279..285
lib/Gallery/Album.php on lines 317..323
lib/Gallery/Image.php on lines 278..284
lib/Gallery/Image.php on lines 460..466
lib/Glossary/Entry.php on lines 302..306
lib/Locations/Correction.php on lines 118..124
lib/News/Article.php on lines 941..945
lib/Prerender/Prerender.php on lines 89..94
lib/Railcams/Photo.php on lines 143..147
lib/Railcams/Storage.php on lines 95..101
lib/Railcams/Storage.php on lines 110..116
lib/SiteMessages/SiteMessage.php on lines 206..210
lib/Timetables/Timetables.php on lines 52..56
lib/Timetables/Timetables.php on lines 64..68
lib/Timetables/Timetables.php on lines 76..80
lib/Users/SockpuppetManager.php on lines 61..67
lib/Warnings/Warning.php on lines 249..255
lib/Warnings/Warning.php on lines 267..273
lib/AppCore.php on lines 401..407
lib/AppCore.php on lines 416..422
lib/AppCore.php on lines 431..437
lib/AppCore.php on lines 463..469
lib/AppCore.php on lines 478..484

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 23.

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 10 locations. Consider refactoring.
Open

        if (!$storageObject instanceof Storage) {
            throw new Exception("Cannot store railcam footage - could not find a suitable storage destination"); 
        }
Severity: Major
Found in lib/Railcams/Footage.php and 9 other locations - About 35 mins to fix
lib/Chronicle/Provider/Locos.php on lines 45..47
lib/Chronicle/Provider/Locos.php on lines 49..51
lib/Chronicle/Provider/Railcams.php on lines 49..51
lib/Chronicle/Provider/Railcams.php on lines 53..55
lib/Events/Event.php on lines 388..390
lib/Locos/Locos.php on lines 769..771
lib/Locos/Locos.php on lines 772..774
lib/Notifications/Notification.php on lines 304..306
lib/Users/Group.php on lines 352..354

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 7 locations. Consider refactoring.
Open

        $data = $this->db->fetchRow("SELECT * FROM railcam_footage WHERE id = ?", $this->id); 
Severity: Major
Found in lib/Railcams/Footage.php and 6 other locations - About 30 mins to fix
lib/Gallery/Image.php on lines 263..263
lib/Gallery/Image.php on lines 401..401
lib/Images/Camera.php on lines 158..158
lib/Links/Category.php on lines 97..97
lib/Locos/Date.php on lines 147..147
lib/News/Topic.php on lines 348..348

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

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

        $this->setCamera(new Camera($data['railcam_id'])); 
Severity: Minor
Found in lib/Railcams/Footage.php and 2 other locations - About 30 mins to fix
lib/Notifications/Notification.php on lines 141..141
lib/Railcams/Storage.php on lines 204..204

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

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

    }
Severity: Minor
Found in lib/Railcams/Footage.php by phpcodesniffer

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

    }
Severity: Minor
Found in lib/Railcams/Footage.php by phpcodesniffer

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

    }
Severity: Minor
Found in lib/Railcams/Footage.php by phpcodesniffer

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

    }
Severity: Minor
Found in lib/Railcams/Footage.php by phpcodesniffer

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

    }
Severity: Minor
Found in lib/Railcams/Footage.php by phpcodesniffer

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

    }
Severity: Minor
Found in lib/Railcams/Footage.php by phpcodesniffer

There are no issues that match your filters.

Category
Status