railpage/railpagecore

View on GitHub
lib/Events/Events.php

Summary

Maintainability
B
6 hrs
Test Coverage

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

    public function yieldPendingEventDates() {
        $query = "SELECT id FROM event_dates WHERE status = ?";
        
        foreach ($this->db->fetchAll($query, self::STATUS_UNAPPROVED) as $row) {
            yield new EventDate($row['id']);
Severity: Major
Found in lib/Events/Events.php and 2 other locations - About 1 hr to fix
lib/Chronicle/Chronicle.php on lines 62..68
lib/Events/Events.php on lines 156..162

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

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

    public function yieldPendingEvents() {
        $query = "SELECT id FROM event WHERE status = ?";
        
        foreach ($this->db->fetchAll($query, self::STATUS_UNAPPROVED) as $row) {
            yield new Event($row['id']);
Severity: Major
Found in lib/Events/Events.php and 2 other locations - About 1 hr to fix
lib/Chronicle/Chronicle.php on lines 62..68
lib/Events/Events.php on lines 170..176

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

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

    public function __construct() {
        parent::__construct(); 
        
        $this->Module = new Module("events");
        $this->namespace = $this->Module->namespace;
Severity: Major
Found in lib/Events/Events.php and 4 other locations - About 1 hr to fix
lib/Locations/Locations.php on lines 48..53
lib/News/Base.php on lines 44..49
lib/Organisations/Base.php on lines 35..40
lib/Railcams/Railcams.php on lines 30..35

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

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

        if (!filter_var($orgObject->id, FILTER_VALIDATE_INT)) {
            throw new Exception("Cannot fetch upcoming events because the specified organisation is invalid or doesn't exist");
        }
Severity: Major
Found in lib/Events/Events.php and 24 other locations - About 1 hr to fix
lib/Downloads/Download.php on lines 313..315
lib/Events/Event.php on lines 425..427
lib/Images/Competition.php on lines 624..626
lib/Images/Competition.php on lines 654..656
lib/Images/Competition.php on lines 823..825
lib/Images/Competition.php on lines 860..862
lib/Images/Favourites.php on lines 112..114
lib/Images/Favourites.php on lines 178..180
lib/Jobs/Classification.php on lines 80..82
lib/Locations/Location.php on lines 406..408
lib/Locations/Location.php on lines 410..412
lib/Locos/Locomotive.php on lines 622..624
lib/Locos/Locomotive.php on lines 626..628
lib/Locos/Locomotive.php on lines 897..899
lib/News/Article.php on lines 361..363
lib/News/Article.php on lines 834..836
lib/Newsletters/Newsletters.php on lines 135..137
lib/PrivateMessages/Message.php on lines 244..246
lib/PrivateMessages/Message.php on lines 452..454
lib/Railcams/Photo.php on lines 330..332
lib/Railcams/Storage.php on lines 224..226
lib/Sightings/Sighting.php on lines 133..135
lib/Users/Group.php on lines 236..238
lib/Warnings/Warning.php on lines 209..211

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

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

        if (!$dateObject instanceof DateTime) {
            $dateObject = new DateTime;
        }
Severity: Major
Found in lib/Events/Events.php and 4 other locations - About 40 mins to fix
lib/Chronicle/Chronicle.php on lines 79..81
lib/Events/EventCategory.php on lines 182..184
lib/Organisations/Organisation.php on lines 421..423
lib/Users/Base.php on lines 149..151

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

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

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

There are no issues that match your filters.

Category
Status