XoopsModules25x/apcal

View on GitHub
include/Text_Diff_Renderer_inline.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '153', column '21').
Open

        $diff = new Text_Diff($this->_splitOnWords($text1, $nl), $this->_splitOnWords($text2, $nl));
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '156', column '25').
Open

        $renderer = new Text_Diff_Renderer_inline(array_merge($this->getParams(), array('split_level' => 'words')));
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method _lines has a boolean flag argument $encode, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function _lines($lines, $prefix = ' ', $encode = true)
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method _deleted has a boolean flag argument $words, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function _deleted($lines, $words = false)
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method _lines uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            return implode("\n", $lines) . "\n";
        }
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid unused parameters such as '$xbeg'.
Open

    public function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$prefix'.
Open

    public function _lines($lines, $prefix = ' ', $encode = true)
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$ybeg'.
Open

    public function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$ylen'.
Open

    public function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$words'.
Open

    public function _deleted($lines, $words = false)
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$xlen'.
Open

    public function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid excessively long variable names like $_leading_context_lines. Keep variable name length under 20.
Open

    public $_leading_context_lines = 10000;
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $_trailing_context_lines. Keep variable name length under 20.
Open

    public $_trailing_context_lines = 10000;
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Text_Diff_Renderer_inline extends Text_Diff_Renderer

The property $_ins_suffix is not named in camelCase.
Open

class Text_Diff_Renderer_inline extends Text_Diff_Renderer
{
    /**
     * Number of leading context "lines" to preserve.
     */
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The property $_block_header is not named in camelCase.
Open

class Text_Diff_Renderer_inline extends Text_Diff_Renderer
{
    /**
     * Number of leading context "lines" to preserve.
     */
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The property $_split_level is not named in camelCase.
Open

class Text_Diff_Renderer_inline extends Text_Diff_Renderer
{
    /**
     * Number of leading context "lines" to preserve.
     */
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The property $_leading_context_lines is not named in camelCase.
Open

class Text_Diff_Renderer_inline extends Text_Diff_Renderer
{
    /**
     * Number of leading context "lines" to preserve.
     */
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The property $_trailing_context_lines is not named in camelCase.
Open

class Text_Diff_Renderer_inline extends Text_Diff_Renderer
{
    /**
     * Number of leading context "lines" to preserve.
     */
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The property $_del_suffix is not named in camelCase.
Open

class Text_Diff_Renderer_inline extends Text_Diff_Renderer
{
    /**
     * Number of leading context "lines" to preserve.
     */
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The property $_ins_prefix is not named in camelCase.
Open

class Text_Diff_Renderer_inline extends Text_Diff_Renderer
{
    /**
     * Number of leading context "lines" to preserve.
     */
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The class Text_Diff_Renderer_inline is not named in CamelCase.
Open

class Text_Diff_Renderer_inline extends Text_Diff_Renderer
{
    /**
     * Number of leading context "lines" to preserve.
     */
Severity: Minor
Found in include/Text_Diff_Renderer_inline.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

The property $_del_prefix is not named in camelCase.
Open

class Text_Diff_Renderer_inline extends Text_Diff_Renderer
{
    /**
     * Number of leading context "lines" to preserve.
     */
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

Avoid variables with short names like $nl. Configured minimum length is 3.
Open

        $nl = "\0";
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Property name "$_leading_context_lines" should not be prefixed with an underscore to indicate visibility
Open

    public $_leading_context_lines = 10000;

Method name "_deleted" should not be prefixed with an underscore to indicate visibility
Open

    public function _deleted($lines, $words = false)

Property name "$_ins_suffix" should not be prefixed with an underscore to indicate visibility
Open

    public $_ins_suffix = '</ins>';

Method name "_added" should not be prefixed with an underscore to indicate visibility
Open

    public function _added($lines)

Property name "$_block_header" should not be prefixed with an underscore to indicate visibility
Open

    public $_block_header = '';

Property name "$_ins_prefix" should not be prefixed with an underscore to indicate visibility
Open

    public $_ins_prefix = '<ins>';

Method name "_startBlock" should not be prefixed with an underscore to indicate visibility
Open

    public function _startBlock($header)

Method name "_splitOnWords" should not be prefixed with an underscore to indicate visibility
Open

    public function _splitOnWords($string, $newlineEscape = "\n")

Method name "_changed" should not be prefixed with an underscore to indicate visibility
Open

    public function _changed($orig, $final)

Method name "_encode" should not be prefixed with an underscore to indicate visibility
Open

    public function _encode(&$string)

Property name "$_split_level" should not be prefixed with an underscore to indicate visibility
Open

    public $_split_level = 'lines';

Method name "_blockHeader" should not be prefixed with an underscore to indicate visibility
Open

    public function _blockHeader($xbeg, $xlen, $ybeg, $ylen)

Method name "_lines" should not be prefixed with an underscore to indicate visibility
Open

    public function _lines($lines, $prefix = ' ', $encode = true)

Property name "$_del_prefix" should not be prefixed with an underscore to indicate visibility
Open

    public $_del_prefix = '<del>';

Property name "$_trailing_context_lines" should not be prefixed with an underscore to indicate visibility
Open

    public $_trailing_context_lines = 10000;

Property name "$_del_suffix" should not be prefixed with an underscore to indicate visibility
Open

    public $_del_suffix = '</del>';

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

class Text_Diff_Renderer_inline extends Text_Diff_Renderer

The method _encode is not named in camelCase.
Open

    public function _encode(&$string)
    {
        $string = htmlspecialchars($string);
    }
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method _deleted is not named in camelCase.
Open

    public function _deleted($lines, $words = false)
    {
        array_walk($lines, array(&$this, '_encode'));
        $lines[0]                 = $this->_del_prefix . $lines[0];
        $lines[count($lines) - 1] .= $this->_del_suffix;
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method _added is not named in camelCase.
Open

    public function _added($lines)
    {
        array_walk($lines, array(&$this, '_encode'));
        $lines[0]                 = $this->_ins_prefix . $lines[0];
        $lines[count($lines) - 1] .= $this->_ins_suffix;
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method _blockHeader is not named in camelCase.
Open

    public function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
    {
        return $this->_block_header;
    }
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method _changed is not named in camelCase.
Open

    public function _changed($orig, $final)
    {
        /* If we've already split on words, don't try to do so again - just
         * display. */
        if ($this->_split_level === 'words') {
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method _lines is not named in camelCase.
Open

    public function _lines($lines, $prefix = ' ', $encode = true)
    {
        if ($encode) {
            array_walk($lines, array(&$this, '_encode'));
        }
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method _splitOnWords is not named in camelCase.
Open

    public function _splitOnWords($string, $newlineEscape = "\n")
    {
        $words  = array();
        $length = strlen($string);
        $pos    = 0;
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method _startBlock is not named in camelCase.
Open

    public function _startBlock($header)
    {
        return $header;
    }
Severity: Minor
Found in include/Text_Diff_Renderer_inline.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status