railpage/railpagecore

View on GitHub
lib/Template_Cache_Memcached.php

Summary

Maintainability
B
5 hrs
Test Coverage

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

            $rs = $this->Cache->set($k, $v, 0, $expire);
Severity: Minor
Found in lib/Template_Cache_Memcached.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

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

    protected function write(array $keys, $expire=null)
    {   
        #echo "writing template to cache";
        #printArray($keys);
        foreach ($keys as $k => $v) {
Severity: Major
Found in lib/Template_Cache_Memcached.php and 1 other location - About 2 hrs to fix
lib/Template_Cache_Memcache.php on lines 88..97

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

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

    protected function delete(array $keys)
    {
        
        #$this->Cache->deleteMulti($keys); 
        
Severity: Major
Found in lib/Template_Cache_Memcached.php and 2 other locations - About 1 hr to fix
lib/Template_Cache_Memcache.php on lines 105..114
lib/Template_Cache_Redis.php on lines 102..111

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

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

        $host = defined("RP_MEMCACHE_HOST") ? RP_MEMCACHE_HOST : "cache.railpage.com.au";
Severity: Minor
Found in lib/Template_Cache_Memcached.php and 2 other locations - About 40 mins to fix
lib/Url.php on lines 60..60
lib/Url.php on lines 61..61

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 class Template_Cache_Memcached is not named in CamelCase.
Open

class Template_Cache_Memcached extends Smarty_CacheResource_KeyValueStore {
    
    /**
     * Cache instance
     * @var Cache
Severity: Minor
Found in lib/Template_Cache_Memcached.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Incorrect spacing between default value and equals sign for argument "$expire"; expected 1 but found 0
Open

    protected function write(array $keys, $expire=null)

Incorrect spacing between argument "$expire" and equals sign; expected 1 but found 0
Open

    protected function write(array $keys, $expire=null)

There must be one blank line after the namespace declaration
Open

namespace Railpage;

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

    }

Class name "Template_Cache_Memcached" is not in camel caps format
Open

class Template_Cache_Memcached extends Smarty_CacheResource_KeyValueStore {

There are no issues that match your filters.

Category
Status