features/irc/lib.php

Summary

Maintainability
B
4 hrs
Test Coverage

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

    static function get_irc_channels_for_event($event_id, $conn = null) {
        $conn = $conn ?: Persistence::get_database_object();
        $columns = array('id', 'channel');
        $table_name = 'irc';
        $where = array(
Severity: Major
Found in features/irc/lib.php and 3 other locations - About 2 hrs to fix
features/images/lib.php on lines 19..33
features/jira/lib.php on lines 19..33
phplib/Postmortem.php on lines 219..233

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

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

    static function get_channel($theid, $conn = null) {
        $conn = $conn ?: Persistence::get_database_object();
        $columns = array('id', 'channel');
        $table_name = 'irc';
        if (is_null($conn)) {
Severity: Major
Found in features/irc/lib.php and 3 other locations - About 1 hr to fix
features/images/lib.php on lines 84..93
features/jira/lib.php on lines 84..93
features/slack/lib.php on lines 284..293

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

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

    static function save_irc_channels_for_event($event_id, $channels, $conn = null) {
        $conn = $conn ?: Persistence::get_database_object();
        $table_name = 'irc';
        $assoc_column = 'channel';
        if (is_null($conn)) {
Severity: Major
Found in features/irc/lib.php and 2 other locations - About 1 hr to fix
features/images/lib.php on lines 45..55
features/jira/lib.php on lines 45..55

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

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

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

class Irc {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Visibility must be declared on method "get_irc_channels_list"
Open

    static function get_irc_channels_list(){
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Visibility must be declared on method "get_irc_channels_for_event"
Open

    static function get_irc_channels_for_event($event_id, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Visibility must be declared on method "get_channel"
Open

    static function get_channel($theid, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Visibility must be declared on method "delete_channel"
Open

    static function delete_channel($theid, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Method name "Irc::undelete_channel" is not in camel caps format
Open

    static function undelete_channel($theid, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Visibility must be declared on method "save_irc_channels_for_event"
Open

    static function save_irc_channels_for_event($event_id, $channels, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Method name "Irc::delete_irc_channels_for_event" is not in camel caps format
Open

    static function delete_irc_channels_for_event($event_id, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Visibility must be declared on method "undelete_channel"
Open

    static function undelete_channel($theid, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Opening brace of a class must be on the line after the definition
Open

class Irc {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Visibility must be declared on method "delete_irc_channels_for_event"
Open

    static function delete_irc_channels_for_event($event_id, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Method name "Irc::get_irc_channels_list" is not in camel caps format
Open

    static function get_irc_channels_list(){
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Method name "Irc::save_irc_channels_for_event" is not in camel caps format
Open

    static function save_irc_channels_for_event($event_id, $channels, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Method name "Irc::delete_channel" is not in camel caps format
Open

    static function delete_channel($theid, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Expected 1 blank line at end of file; 2 found
Open

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

Method name "Irc::get_channel" is not in camel caps format
Open

    static function get_channel($theid, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

The closing brace for the class must go on the next line after the body
Open

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

Method name "Irc::get_irc_channels_for_event" is not in camel caps format
Open

    static function get_irc_channels_for_event($event_id, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Only one argument is allowed per line in a multi-line function call
Open

        return Persistence::store_array($table_name, $assoc_column, $channels,
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Only one argument is allowed per line in a multi-line function call
Open

        return Persistence::store_array($table_name, $assoc_column, $channels,
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Only one argument is allowed per line in a multi-line function call
Open

                                        $event_id, $conn);
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Closing parenthesis of a multi-line function call must be on a line by itself
Open

                                        $event_id, $conn);
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

    static function delete_irc_channels_for_event($event_id, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

    static function save_irc_channels_for_event($event_id, $channels, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

    static function get_irc_channels_list(){
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

    static function get_irc_channels_for_event($event_id, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Multi-line function call not indented correctly; expected 8 spaces but found 40
Open

                                        $event_id, $conn);
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

    static function undelete_channel($theid, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

    static function delete_channel($theid, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

    static function get_channel($theid, $conn = null) {
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

Opening parenthesis of a multi-line function call must be the last content on the line
Open

        return Persistence::store_array($table_name, $assoc_column, $channels,
Severity: Minor
Found in features/irc/lib.php by phpcodesniffer

There are no issues that match your filters.

Category
Status