features/jira/lib.php

Summary

Maintainability
B
5 hrs
Test Coverage

Function unpackTicketInfo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function unpackTicketInfo($ticket_info, $fields) {
        $ticket = array();
        foreach($fields as $k => $v) {
            # set a default value
            $ticket[$k] = "";
Severity: Minor
Found in features/jira/lib.php - About 55 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 merge_jira_tickets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    static function merge_jira_tickets($tickets, $curl = null) {
        if (empty($tickets)) {
            return array();
        }

Severity: Minor
Found in features/jira/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_jira_tickets_for_event($event_id, $conn = null) {
        $conn = $conn ?: Persistence::get_database_object();
        $columns = array('id', 'ticket');
        $table = 'jira';
        $where = array(
Severity: Major
Found in features/jira/lib.php and 3 other locations - About 2 hrs to fix
features/images/lib.php on lines 19..33
features/irc/lib.php on lines 36..50
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 3 locations. Consider refactoring.
Open

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

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 4 locations. Consider refactoring.
Open

    static function get_ticket($theid, $conn = null) {
        $conn = $conn ?: Persistence::get_database_object();
        $columns = array('id', 'ticket');
        $table_name = 'jira';
        if (is_null($conn)) {
Severity: Major
Found in features/jira/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/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

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

class JiraClient {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

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

class Jira {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Each class must be in a file by itself
Open

class JiraClient {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Method name "Jira::get_ticket" is not in camel caps format
Open

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

Method name "Jira::save_jira_tickets_for_event" is not in camel caps format
Open

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

Method name "Jira::delete_ticket" is not in camel caps format
Open

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

Method name "Jira::merge_jira_tickets" is not in camel caps format
Open

    static function merge_jira_tickets($tickets, $curl = null) {
Severity: Minor
Found in features/jira/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/jira/lib.php by phpcodesniffer

Method name "Jira::get_jira_tickets_for_event" is not in camel caps format
Open

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

Visibility must be declared on method "get_jira_tickets_for_event"
Open

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

Method name "Jira::delete_jira_tickets_for_event" is not in camel caps format
Open

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

Visibility must be declared on method "get_ticket"
Open

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

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

class Jira {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Visibility must be declared on method "merge_jira_tickets"
Open

    static function merge_jira_tickets($tickets, $curl = null) {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

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

class JiraClient {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Visibility must be declared on method "save_jira_tickets_for_event"
Open

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

Visibility must be declared on method "delete_jira_tickets_for_event"
Open

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

Method name "Jira::undelete_ticket" is not in camel caps format
Open

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

Visibility must be declared on method "getJiraApiResponse"
Open

    function getJiraApiResponse($jira_key_input, $fields) {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Visibility must be declared on method "delete_ticket"
Open

    static function delete_ticket($theid, $conn = null) {
Severity: Minor
Found in features/jira/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/jira/lib.php by phpcodesniffer

Visibility must be declared on method "undelete_ticket"
Open

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

Space found before comma in function call
Open

        $response = $this->curl_client->get($this->getJiraBaseUrl() . '/rest/api/2/search' , $params, $this->username . ':' . $this->password, $this->proxy);
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Visibility must be declared on method "__construct"
Open

    function __construct($curl_client, $config = null) {
Severity: Minor
Found in features/jira/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/jira/lib.php by phpcodesniffer

Visibility must be declared on method "getJiraTickets"
Open

    function getJiraTickets($jira_key_input, $api_response = null) {
Severity: Minor
Found in features/jira/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, $tickets,
Severity: Minor
Found in features/jira/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/jira/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, $tickets,
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

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

Opening brace should be on a new line
Open

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

Opening brace should be on a new line
Open

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

Opening brace should be on a new line
Open

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

Opening brace should be on a new line
Open

    static function merge_jira_tickets($tickets, $curl = null) {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Expected 1 space after FOREACH keyword; 0 found
Open

        foreach($tickets as $k => $v) {
Severity: Minor
Found in features/jira/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/jira/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/jira/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, $tickets,
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

    function __construct($curl_client, $config = null) {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

    public function unpackTicketInfo($ticket_info, $fields) {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

    public function getAdditionalIssueFields() {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

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

Expected 1 space after FOREACH keyword; 0 found
Open

        foreach($fields as $k => $v) {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

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

Opening brace should be on a new line
Open

    function getJiraApiResponse($jira_key_input, $fields) {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

A closing tag is not permitted at the end of a PHP file
Open

?>
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

    public function getJiraBaseUrl() {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Opening brace should be on a new line
Open

    function getJiraTickets($jira_key_input, $api_response = null) {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

There are no issues that match your filters.

Category
Status