railpage/railpagecore

View on GitHub
lib/Images/Collection.php

Summary

Maintainability
C
1 day
Test Coverage

Function validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function validate() {
        
        if (empty($this->name)) {
            throw new Exception("Title cannot be empty"); 
        }
Severity: Minor
Found in lib/Images/Collection.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

        if (filter_var($this->id, FILTER_VALIDATE_INT)) {
            $where = [ "id = ?" => $this->id ];
            $this->db->update("image_collection", $data, $where); 
        }
Severity: Major
Found in lib/Images/Collection.php and 4 other locations - About 2 hrs to fix
lib/Downloads/Category.php on lines 170..176
lib/Gallery/Album.php on lines 494..497
lib/Images/Camera.php on lines 192..196
lib/Images/Competition.php on lines 321..327

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

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 (!filter_var($this->id, FILTER_VALIDATE_INT)) {
            $this->db->insert("image_collection", $data); 
            $this->id = $this->db->lastInsertId(); 
        }
Severity: Major
Found in lib/Images/Collection.php and 4 other locations - About 1 hr to fix
lib/Downloads/Category.php on lines 178..181
lib/Gallery/Album.php on lines 500..503
lib/Images/Camera.php on lines 198..201
lib/Images/Competition.php on lines 329..332

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

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

            "created" => array(
                "absolute" => $this->DateCreated->format("Y-m-d H:i:s"),
                "relative" => ContentUtility::relativeTime($this->DateCreated)
            ),
Severity: Major
Found in lib/Images/Collection.php and 3 other locations - About 1 hr to fix
lib/Images/Collection.php on lines 322..325
lib/Sightings/Sighting.php on lines 193..196
lib/Sightings/Sighting.php on lines 197..200

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

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

            "modified" => array(
                "absolute" => $this->DateModified->format("Y-m-d H:i:s"),
                "relative" => ContentUtility::relativeTime($this->DateModified)
            ),
Severity: Major
Found in lib/Images/Collection.php and 3 other locations - About 1 hr to fix
lib/Images/Collection.php on lines 318..321
lib/Sightings/Sighting.php on lines 193..196
lib/Sightings/Sighting.php on lines 197..200

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

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->DateCreated = new DateTime($row['created'], new DateTimeZone("Australia/Melbourne"));
Severity: Major
Found in lib/Images/Collection.php and 2 other locations - About 1 hr to fix
lib/Downloads/Download.php on lines 213..213
lib/Images/Collection.php on lines 136..136

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

        $this->DateModified = new DateTime($row['modified'], new DateTimeZone("Australia/Melbourne"));
Severity: Major
Found in lib/Images/Collection.php and 2 other locations - About 1 hr to fix
lib/Downloads/Download.php on lines 213..213
lib/Images/Collection.php on lines 135..135

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

        $data = [
            "image_id" => $imageObject->id,
            "namespace" => $this->namespace,
            "namespace_key" => $this->id
        ];
Severity: Major
Found in lib/Images/Collection.php and 5 other locations - About 55 mins to fix
lib/Events/EventCategory.php on lines 149..153
lib/Images/Collection.php on lines 291..295
lib/Locos/Manufacturer.php on lines 162..166
lib/News/Topic.php on lines 375..379
lib/PrivateMessages/Message.php on lines 504..508

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

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

        $where = [
            "image_id = ?" => $imageObject->id,
            "namespace = ?" => $this->namespace,
            "namespace_key = ?" => $this->id
        ];
Severity: Major
Found in lib/Images/Collection.php and 5 other locations - About 55 mins to fix
lib/Events/EventCategory.php on lines 149..153
lib/Images/Collection.php on lines 268..272
lib/Locos/Manufacturer.php on lines 162..166
lib/News/Topic.php on lines 375..379
lib/PrivateMessages/Message.php on lines 504..508

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

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

        if (!$this->DateCreated instanceof DateTime) {
            $this->DateCreated = new DateTime;
        }
Severity: Major
Found in lib/Images/Collection.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/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/Railcams/Footage.php on lines 143..145
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 9 locations. Consider refactoring.
Open

        $this->setAuthor(UsersFactory::CreateUser($row['user_id']));
Severity: Major
Found in lib/Images/Collection.php and 8 other locations - About 30 mins to fix
lib/Events/Event.php on lines 215..215
lib/Events/EventDate.php on lines 163..163
lib/Glossary/Entry.php on lines 170..170
lib/Ideas/Idea.php on lines 172..172
lib/Images/Competition.php on lines 203..203
lib/Locations/Correction.php on lines 144..144
lib/PrivateMessages/Message.php on lines 289..289
lib/PrivateMessages/Message.php on lines 290..290

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/Images/Collection.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/Images/Collection.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/Images/Collection.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/Images/Collection.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/Images/Collection.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/Images/Collection.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/Images/Collection.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/Images/Collection.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/Images/Collection.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/Images/Collection.php by phpcodesniffer

There are no issues that match your filters.

Category
Status