features/slack/lib.php

Summary

Maintainability
B
6 hrs
Test Coverage

Function get_channel_messages_for_datetime_range has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    function get_channel_messages_for_datetime_range($starttime, $endtime, $channel_id) {

        $startTimeInUtcFormat = DateTimeUtil::convertDateTimeToUtcTimezoneTimestamp($starttime);
        $endTimeInUtcFormat   = DateTimeUtil::convertDateTimeToUtcTimezoneTimestamp($endtime);

Severity: Minor
Found in features/slack/lib.php - About 2 hrs 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

Method get_channel_messages_for_datetime_range has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function get_channel_messages_for_datetime_range($starttime, $endtime, $channel_id) {

        $startTimeInUtcFormat = DateTimeUtil::convertDateTimeToUtcTimezoneTimestamp($starttime);
        $endTimeInUtcFormat   = DateTimeUtil::convertDateTimeToUtcTimezoneTimestamp($endtime);

Severity: Minor
Found in features/slack/lib.php - About 1 hr to fix

    Function get_slack_channels_list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        function get_slack_channels_list() {
            if (function_exists("morgue_get_slack_channels_list")) {
                return morgue_get_slack_channels_list();
            } else {
                $queryParam = array(
    Severity: Minor
    Found in features/slack/lib.php - About 35 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

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

        static function save_slack_channels_for_event($event_id, $channel_id, $channel_name, $conn = null) {
            $conn = $conn ?: Persistence::get_database_object();
            if (is_null($conn)) {
                return array("status" => self::ERROR,
                    "error" => "Couldn't get connection object.");
    Severity: Minor
    Found in features/slack/lib.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

    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 = 'slack';
            if (is_null($conn)) {
    Severity: Major
    Found in features/slack/lib.php and 3 other locations - About 1 hr to fix
    features/images/lib.php on lines 84..93
    features/irc/lib.php on lines 101..110
    features/jira/lib.php on lines 84..93

    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 Slack {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

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

    class Slack {
    Severity: Minor
    Found in features/slack/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/slack/lib.php by phpcodesniffer

    Visibility must be declared on method "get_user_list"
    Open

        function get_user_list() {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

            if($userListData->ok != true ) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Space found before closing bracket of FOREACH loop
    Open

            foreach ($allMessages  as $messages ) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Blank line found at start of control structure
    Open

                foreach ($messages as $message) {
    Severity: Minor
    Found in features/slack/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/slack/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/slack/lib.php by phpcodesniffer

    Method name "Slack::get_channel_messages_for_datetime_range" is not in camel caps format
    Open

        function get_channel_messages_for_datetime_range($starttime, $endtime, $channel_id) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

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

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

    Blank line found at end of control structure
    Open

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

    Method name "Slack::delete_slack_channels_for_event" is not in camel caps format
    Open

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

    Visibility must be declared on method "__construct"
    Open

        function __construct(CurlClient $curlClient) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Blank line found at start of control structure
    Open

            foreach ($allMessages  as $messages ) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Method name "Slack::get_user_list" is not in camel caps format
    Open

        function get_user_list() {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Method name "Slack::get_slack_channels_for_event" is not in camel caps format
    Open

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

    Method name "Slack::update_slack_channel_message" is not in camel caps format
    Open

        static function update_slack_channel_message($channel_id, $message, $conn = null) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Visibility must be declared on method "get_channel_messages_for_datetime_range"
    Open

        function get_channel_messages_for_datetime_range($starttime, $endtime, $channel_id) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

            foreach ($allMessages  as $messages ) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Visibility must be declared on method "delete_slack_channels_for_event"
    Open

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

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

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

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

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

    Visibility must be declared on method "get_slack_channels_list"
    Open

        function get_slack_channels_list() {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Method name "Slack::save_slack_channels_for_event" is not in camel caps format
    Open

        static function save_slack_channels_for_event($event_id, $channel_id, $channel_name, $conn = null) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

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

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

    Method name "Slack::get_slack_channels_list" is not in camel caps format
    Open

        function get_slack_channels_list() {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

                if($data->ok == true ) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

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

        }
    Severity: Minor
    Found in features/slack/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/slack/lib.php by phpcodesniffer

    Visibility must be declared on method "save_slack_channels_for_event"
    Open

        static function save_slack_channels_for_event($event_id, $channel_id, $channel_name, $conn = null) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Space found before comma in function call
    Open

                array_push($allMessages , $sortedMessage);
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 1 space before "as"; 2 found
    Open

            foreach ($allMessages  as $messages ) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Visibility must be declared on method "get_slack_channels_for_event"
    Open

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

    Visibility must be declared on method "update_slack_channel_message"
    Open

        static function update_slack_channel_message($channel_id, $message, $conn = null) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

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

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

    Blank line found at start of control structure
    Open

            while($fetch) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

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

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

    Opening brace should be on a new line
    Open

        function get_slack_channels_list() {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 1 space after closing brace; 0 found
    Open

                }else{
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 1 space after CATCH keyword; 0 found
    Open

            } catch(PDOException $e) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        function get_channel_messages_for_datetime_range($starttime, $endtime, $channel_id) {
    Severity: Minor
    Found in features/slack/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/slack/lib.php by phpcodesniffer

    Expected 1 space after IF keyword; 0 found
    Open

            if($userListData->ok != true ) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 1 space after IF keyword; 0 found
    Open

                if($data->ok == true ) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 1 space after ELSE keyword; 0 found
    Open

                }else{
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        static function save_slack_channels_for_event($event_id, $channel_id, $channel_name, $conn = null) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        function get_user_list() {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 1 space after IF keyword; 0 found
    Open

                if($fetchCounter > self::MAX_FETCH_LIMIT) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

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

    Expected 1 space after IF keyword; 0 found
    Open

                if($data->ok != true) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 1 space after IF keyword; 0 found
    Open

                    if( (!isset($message->user))
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 1 space after IF keyword; 0 found
    Open

            if(isset(self::$user_list)) {
    Severity: Minor
    Found in features/slack/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/slack/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

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

    Expected 1 space after WHILE keyword; 0 found
    Open

            while($fetch) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 1 space after CATCH keyword; 0 found
    Open

            } catch(PDOException $e) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        static function update_slack_channel_message($channel_id, $message, $conn = null) {
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Expected 0 spaces after opening bracket; 1 found
    Open

                    if( (!isset($message->user))
    Severity: Minor
    Found in features/slack/lib.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        function __construct(CurlClient $curlClient) {
    Severity: Minor
    Found in features/slack/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/slack/lib.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status