railpage/railpagecore

View on GitHub
lib/Sightings/Sightings.php

Summary

Maintainability
C
1 day
Test Coverage

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

        public function findLoco($loco_id) {
            if (!filter_var($loco_id, FILTER_VALIDATE_INT)) {
                return false;
            }
            
Severity: Major
Found in lib/Sightings/Sightings.php and 1 other location - About 3 hrs to fix
lib/Sightings/Sightings.php on lines 84..98

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

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

        public function findLocoClass($class_id) {
            if (!filter_var($class_id, FILTER_VALIDATE_INT)) {
                return false;
            }
            
Severity: Major
Found in lib/Sightings/Sightings.php and 1 other location - About 3 hrs to fix
lib/Sightings/Sightings.php on lines 62..76

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

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

            foreach ($rs as $row) {
                $Sighting = new Sighting($row['id']); 
                $sightings[] = $Sighting->getArray(); 
            }
Severity: Major
Found in lib/Sightings/Sightings.php and 4 other locations - About 1 hr to fix
lib/Images/Competitions.php on lines 123..126
lib/Locos/Manufacturer.php on lines 192..196
lib/Locos/Type.php on lines 191..195
lib/Newsletters/Newsletters.php on lines 85..88

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

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

            $SphinxPDO = new PDO("mysql:host=" . $Config->Sphinx->Host . ";port=9312"); 
Severity: Major
Found in lib/Sightings/Sightings.php and 2 other locations - About 45 mins to fix
lib/Railcams/Photo.php on lines 339..339
lib/Railcams/Railcams.php on lines 134..134

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

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

            $sightings = $this->db->fetchAll($query, array($thispage, $items_per_page)); 
Severity: Major
Found in lib/Sightings/Sightings.php and 3 other locations - About 45 mins to fix
lib/Forums/Stats.php on lines 96..96
lib/Forums/Thread.php on lines 223..223
lib/Locations/Locations.php on lines 190..190

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

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

            foreach ($sightings as $row) {
                $return['sightings'][] = $row['id']; 
            }
Severity: Minor
Found in lib/Sightings/Sightings.php and 1 other location - About 40 mins to fix
lib/Notifications/Transport/Push.php on lines 68..70

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

The parameter $Loco is not named in camelCase.
Open

        public static function getLocoSightings(Locomotive $Loco) {
            
            $Config = AppCore::GetConfig(); 
            $SphinxPDO = new PDO("mysql:host=" . $Config->Sphinx->Host . ";port=9312"); 
            
Severity: Minor
Found in lib/Sightings/Sightings.php by phpmd

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The parameter $loco_id is not named in camelCase.
Open

        public function findLoco($loco_id) {
            if (!filter_var($loco_id, FILTER_VALIDATE_INT)) {
                return false;
            }
            
Severity: Minor
Found in lib/Sightings/Sightings.php by phpmd

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The parameter $class_id is not named in camelCase.
Open

        public function findLocoClass($class_id) {
            if (!filter_var($class_id, FILTER_VALIDATE_INT)) {
                return false;
            }
            
Severity: Minor
Found in lib/Sightings/Sightings.php by phpmd

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The parameter $items_per_page is not named in camelCase.
Open

        public function latest($items_per_page = 25, $page = 1) {
            $thispage = ($page - 1) * $items_per_page;
            
            $query = "SELECT SQL_CALC_FOUND_ROWS id FROM sighting ORDER BY date DESC LIMIT ?, ?";
            
Severity: Minor
Found in lib/Sightings/Sightings.php by phpmd

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

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

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

Line indented incorrectly; expected 8 spaces, found 12
Open

            foreach ($this->db->fetchAll($query, $loco_id) as $row) {
Severity: Minor
Found in lib/Sightings/Sightings.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 12
Open

            foreach ($this->db->fetchAll($query, $class_id) as $row) {
Severity: Minor
Found in lib/Sightings/Sightings.php by phpcodesniffer

Line indented incorrectly; expected 4 spaces, found 8
Open

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

Line indented incorrectly; expected 4 spaces, found 8
Open

        public function latest($items_per_page = 25, $page = 1) {
Severity: Minor
Found in lib/Sightings/Sightings.php by phpcodesniffer

Line indented incorrectly; expected 4 spaces, found 8
Open

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

Line indented incorrectly; expected 8 spaces, found 12
Open

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

Line indented incorrectly; expected 8 spaces, found 12
Open

            if (!filter_var($loco_id, FILTER_VALIDATE_INT)) {
Severity: Minor
Found in lib/Sightings/Sightings.php by phpcodesniffer

Line indented incorrectly; expected 4 spaces, found 8
Open

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

Line indented incorrectly; expected 8 spaces, found 12
Open

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

Line indented incorrectly; expected 8 spaces, found 12
Open

            foreach ($rs as $row) {
Severity: Minor
Found in lib/Sightings/Sightings.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 12
Open

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

Line indented incorrectly; expected 0 spaces, found 4
Open

    class Sightings extends AppCore {
Severity: Minor
Found in lib/Sightings/Sightings.php by phpcodesniffer

Line indented incorrectly; expected 4 spaces, found 8
Open

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

Line indented incorrectly; expected 8 spaces, found 12
Open

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

Line indented incorrectly; expected 4 spaces, found 8
Open

        public function findLocoClass($class_id) {
Severity: Minor
Found in lib/Sightings/Sightings.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 12
Open

            foreach ($sightings as $row) {
Severity: Minor
Found in lib/Sightings/Sightings.php by phpcodesniffer

Line indented incorrectly; expected 4 spaces, found 8
Open

        public static function getLocoSightings(Locomotive $Loco) {
Severity: Minor
Found in lib/Sightings/Sightings.php by phpcodesniffer

Line indented incorrectly; expected 0 spaces, found 4
Open

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

Line indented incorrectly; expected 8 spaces, found 12
Open

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

Line indented incorrectly; expected 4 spaces, found 8
Open

        public function findLoco($loco_id) {
Severity: Minor
Found in lib/Sightings/Sightings.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 12
Open

            if (!filter_var($class_id, FILTER_VALIDATE_INT)) {
Severity: Minor
Found in lib/Sightings/Sightings.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 12
Open

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

There are no issues that match your filters.

Category
Status