XoopsModules25x/apcal

View on GitHub
assets/js/jscalendar/calendar.php

Summary

Maintainability
A
25 mins
Test Coverage

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

    public function _make_js_hash($array)
    {
        $jstr = '';
//        reset($array);
//        while (list($key, $val) = each($array)) {
Severity: Minor
Found in assets/js/jscalendar/calendar.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

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

        $stripped = true
Severity: Minor
Found in assets/js/jscalendar/calendar.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 __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->calendar_file       = 'calendar.js';
            $this->calendar_setup_file = 'calendar-setup.js';
        }
Severity: Minor
Found in assets/js/jscalendar/calendar.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

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

class DHTML_Calendar

The property $calendar_setup_file is not named in camelCase.
Open

class DHTML_Calendar
{
    public $calendar_lib_path;

    public $calendar_file;
Severity: Minor
Found in assets/js/jscalendar/calendar.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 $id. Configured minimum length is 3.
Open

    public function _trigger_id($id)
Severity: Minor
Found in assets/js/jscalendar/calendar.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

The parameter $calendar_lib_path is not named in camelCase.
Open

    public function __construct(
        $calendar_lib_path = '/calendar/',
        $lang = 'en',
        $theme = 'calendar-win2k-1',
        $stripped = true
Severity: Minor
Found in assets/js/jscalendar/calendar.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 $cal_options is not named in camelCase.
Open

    public function make_input_field($cal_options = array(), $field_attributes = array())
    {
        $id      = $this->_gen_id();
        $attrstr = $this->_make_html_attr(array_merge($field_attributes, array(
            'id'   => $this->_field_id($id),
Severity: Minor
Found in assets/js/jscalendar/calendar.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 property $calendar_file is not named in camelCase.
Open

class DHTML_Calendar
{
    public $calendar_lib_path;

    public $calendar_file;
Severity: Minor
Found in assets/js/jscalendar/calendar.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 $id. Configured minimum length is 3.
Open

        static $id = 0;
Severity: Minor
Found in assets/js/jscalendar/calendar.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

The class DHTML_Calendar is not named in CamelCase.
Open

class DHTML_Calendar
{
    public $calendar_lib_path;

    public $calendar_file;
Severity: Minor
Found in assets/js/jscalendar/calendar.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 $calendar_lib_path is not named in camelCase.
Open

class DHTML_Calendar
{
    public $calendar_lib_path;

    public $calendar_file;
Severity: Minor
Found in assets/js/jscalendar/calendar.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 $calendar_options is not named in camelCase.
Open

class DHTML_Calendar
{
    public $calendar_lib_path;

    public $calendar_file;
Severity: Minor
Found in assets/js/jscalendar/calendar.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 $id. Configured minimum length is 3.
Open

    public function _field_id($id)
Severity: Minor
Found in assets/js/jscalendar/calendar.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

The parameter $other_options is not named in camelCase.
Open

    public function _make_calendar($other_options = array())
    {
        $js_options = $this->_make_js_hash(array_merge($this->calendar_options, $other_options));
        $code       = ('<script type="text/javascript">Calendar.setup({' . $js_options . '});</script>');

Severity: Minor
Found in assets/js/jscalendar/calendar.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 property $calendar_lang_file is not named in camelCase.
Open

class DHTML_Calendar
{
    public $calendar_lib_path;

    public $calendar_file;
Severity: Minor
Found in assets/js/jscalendar/calendar.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 $id. Configured minimum length is 3.
Open

        $id      = $this->_gen_id();
Severity: Minor
Found in assets/js/jscalendar/calendar.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

The property $calendar_theme_file is not named in camelCase.
Open

class DHTML_Calendar
{
    public $calendar_lib_path;

    public $calendar_file;
Severity: Minor
Found in assets/js/jscalendar/calendar.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 parameter $field_attributes is not named in camelCase.
Open

    public function make_input_field($cal_options = array(), $field_attributes = array())
    {
        $id      = $this->_gen_id();
        $attrstr = $this->_make_html_attr(array_merge($field_attributes, array(
            'id'   => $this->_field_id($id),
Severity: Minor
Found in assets/js/jscalendar/calendar.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

Method name "DHTML_Calendar::_gen_id" is not in camel caps format
Open

    public function _gen_id()

Method name "DHTML_Calendar::_make_js_hash" is not in camel caps format
Open

    public function _make_js_hash($array)

Method name "DHTML_Calendar::_make_html_attr" is not in camel caps format
Open

    public function _make_html_attr($array)

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

    public function _trigger_id($id)

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

    public function _make_html_attr($array)

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

    public function _gen_id()

Method name "DHTML_Calendar::make_input_field" is not in camel caps format
Open

    public function make_input_field($cal_options = array(), $field_attributes = array())

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

    public function _field_id($id)

Method name "DHTML_Calendar::set_option" is not in camel caps format
Open

    public function set_option($name, $value)

Method name "DHTML_Calendar::get_load_files_code" is not in camel caps format
Open

    public function get_load_files_code()

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

    public function _make_js_hash($array)

Method name "DHTML_Calendar::_make_calendar" is not in camel caps format
Open

    public function _make_calendar($other_options = array())

Method name "DHTML_Calendar::_field_id" is not in camel caps format
Open

    public function _field_id($id)

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

    public function _make_calendar($other_options = array())

Method name "DHTML_Calendar::load_files" is not in camel caps format
Open

    public function load_files()

Method name "DHTML_Calendar::_trigger_id" is not in camel caps format
Open

    public function _trigger_id($id)

Line exceeds 120 characters; contains 130 characters
Open

        $code .= ('<script type="text/javascript" src="' . $this->calendar_lib_path . $this->calendar_setup_file . '"></script>');

Line exceeds 120 characters; contains 134 characters
Open

        $code .= ('<script type="text/javascript" src="' . $this->calendar_lib_path . $this->calendar_file . '"></script>' . NEWLINE);

Line exceeds 120 characters; contains 153 characters
Open

        $code = ('<link rel="stylesheet" type="text/css" media="all" href="' . $this->calendar_lib_path . $this->calendar_theme_file . '" />' . NEWLINE);

Line exceeds 120 characters; contains 139 characters
Open

        $code .= ('<script type="text/javascript" src="' . $this->calendar_lib_path . $this->calendar_lang_file . '"></script>' . NEWLINE);

Line exceeds 120 characters; contains 160 characters
Open

        echo '<a href="#" id="' . $this->_trigger_id($id) . '">' . '<img align="middle" border="0" src="' . $this->calendar_lib_path . 'img.gif" alt="" /></a>';

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

class DHTML_Calendar

The variable $js_options is not named in camelCase.
Open

    public function _make_calendar($other_options = array())
    {
        $js_options = $this->_make_js_hash(array_merge($this->calendar_options, $other_options));
        $code       = ('<script type="text/javascript">Calendar.setup({' . $js_options . '});</script>');

Severity: Minor
Found in assets/js/jscalendar/calendar.php by phpmd

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $js_options is not named in camelCase.
Open

    public function _make_calendar($other_options = array())
    {
        $js_options = $this->_make_js_hash(array_merge($this->calendar_options, $other_options));
        $code       = ('<script type="text/javascript">Calendar.setup({' . $js_options . '});</script>');

Severity: Minor
Found in assets/js/jscalendar/calendar.php by phpmd

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $calendar_lib_path is not named in camelCase.
Open

    public function __construct(
        $calendar_lib_path = '/calendar/',
        $lang = 'en',
        $theme = 'calendar-win2k-1',
        $stripped = true
Severity: Minor
Found in assets/js/jscalendar/calendar.php by phpmd

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $other_options is not named in camelCase.
Open

    public function _make_calendar($other_options = array())
    {
        $js_options = $this->_make_js_hash(array_merge($this->calendar_options, $other_options));
        $code       = ('<script type="text/javascript">Calendar.setup({' . $js_options . '});</script>');

Severity: Minor
Found in assets/js/jscalendar/calendar.php by phpmd

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $cal_options is not named in camelCase.
Open

    public function make_input_field($cal_options = array(), $field_attributes = array())
    {
        $id      = $this->_gen_id();
        $attrstr = $this->_make_html_attr(array_merge($field_attributes, array(
            'id'   => $this->_field_id($id),
Severity: Minor
Found in assets/js/jscalendar/calendar.php by phpmd

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $field_attributes is not named in camelCase.
Open

    public function make_input_field($cal_options = array(), $field_attributes = array())
    {
        $id      = $this->_gen_id();
        $attrstr = $this->_make_html_attr(array_merge($field_attributes, array(
            'id'   => $this->_field_id($id),
Severity: Minor
Found in assets/js/jscalendar/calendar.php by phpmd

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The method _make_calendar is not named in camelCase.
Open

    public function _make_calendar($other_options = array())
    {
        $js_options = $this->_make_js_hash(array_merge($this->calendar_options, $other_options));
        $code       = ('<script type="text/javascript">Calendar.setup({' . $js_options . '});</script>');

Severity: Minor
Found in assets/js/jscalendar/calendar.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 load_files is not named in camelCase.
Open

    public function load_files()
    {
        echo $this->get_load_files_code();
    }
Severity: Minor
Found in assets/js/jscalendar/calendar.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 _make_html_attr is not named in camelCase.
Open

    public function _make_html_attr($array)
    {
        $attrstr = '';
//        reset($array);
//        while (list($key, $val) = each($array)) {
Severity: Minor
Found in assets/js/jscalendar/calendar.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 get_load_files_code is not named in camelCase.
Open

    public function get_load_files_code()
    {
        $code = ('<link rel="stylesheet" type="text/css" media="all" href="' . $this->calendar_lib_path . $this->calendar_theme_file . '" />' . NEWLINE);
        $code .= ('<script type="text/javascript" src="' . $this->calendar_lib_path . $this->calendar_file . '"></script>' . NEWLINE);
        $code .= ('<script type="text/javascript" src="' . $this->calendar_lib_path . $this->calendar_lang_file . '"></script>' . NEWLINE);
Severity: Minor
Found in assets/js/jscalendar/calendar.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 _gen_id is not named in camelCase.
Open

    public function _gen_id()
    {
        static $id = 0;

        return ++$id;
Severity: Minor
Found in assets/js/jscalendar/calendar.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 _trigger_id is not named in camelCase.
Open

    public function _trigger_id($id)
    {
        return 'f-calendar-trigger-' . $id;
    }
Severity: Minor
Found in assets/js/jscalendar/calendar.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 set_option is not named in camelCase.
Open

    public function set_option($name, $value)
    {
        $this->calendar_options[$name] = $value;
    }
Severity: Minor
Found in assets/js/jscalendar/calendar.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 make_input_field is not named in camelCase.
Open

    public function make_input_field($cal_options = array(), $field_attributes = array())
    {
        $id      = $this->_gen_id();
        $attrstr = $this->_make_html_attr(array_merge($field_attributes, array(
            'id'   => $this->_field_id($id),
Severity: Minor
Found in assets/js/jscalendar/calendar.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 _field_id is not named in camelCase.
Open

    public function _field_id($id)
    {
        return 'f-calendar-field-' . $id;
    }
Severity: Minor
Found in assets/js/jscalendar/calendar.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 _make_js_hash is not named in camelCase.
Open

    public function _make_js_hash($array)
    {
        $jstr = '';
//        reset($array);
//        while (list($key, $val) = each($array)) {
Severity: Minor
Found in assets/js/jscalendar/calendar.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