File Postmortem.php
has 394 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
require_once('Persistence.php');
/**
Method save_tags_for_event
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
static function save_tags_for_event($event_id, $tags, $conn = null) {
$conn = $conn ?: Persistence::get_database_object();
if (is_null($conn)) {
return array("status" => self::ERROR,
"error" => "Couldn't get connection object.");
Method delete_tag
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
static function delete_tag($tag_id, $event_id = null, $conn = null) {
$conn = $conn ?: Persistence::get_database_object();
if (is_null($conn)) {
return array("status" => self::ERROR,
"error" => "Couldn't get connection object.");
Method undelete_tag
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
static function undelete_tag($tag_id, $event_id = null, $conn = null) {
$conn = $conn ?: Persistence::get_database_object();
if (is_null($conn)) {
return array("status" => self::ERROR,
"error" => "Couldn't get connection object.");
Method add_history
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
static function add_history($event, $admin, $action, $conn = null) {
// validate action
if (!in_array($action, array(self::ACTION_ADD, self::ACTION_EDIT))) {
return array(
"status" => self::ERROR,
Function save_tags_for_event
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static function save_tags_for_event($event_id, $tags, $conn = null) {
$conn = $conn ?: Persistence::get_database_object();
if (is_null($conn)) {
return array("status" => self::ERROR,
"error" => "Couldn't get connection object.");
- Read upRead up
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 delete_tag
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static function delete_tag($tag_id, $event_id = null, $conn = null) {
$conn = $conn ?: Persistence::get_database_object();
if (is_null($conn)) {
return array("status" => self::ERROR,
"error" => "Couldn't get connection object.");
- Read upRead up
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 undelete_tag
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static function undelete_tag($tag_id, $event_id = null, $conn = null) {
$conn = $conn ?: Persistence::get_database_object();
if (is_null($conn)) {
return array("status" => self::ERROR,
"error" => "Couldn't get connection object.");
- Read upRead up
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 2 locations. Consider refactoring. Open
static function delete_tag($tag_id, $event_id = null, $conn = null) {
$conn = $conn ?: Persistence::get_database_object();
if (is_null($conn)) {
return array("status" => self::ERROR,
"error" => "Couldn't get connection object.");
- Read upRead up
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 323.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
static function undelete_tag($tag_id, $event_id = null, $conn = null) {
$conn = $conn ?: Persistence::get_database_object();
if (is_null($conn)) {
return array("status" => self::ERROR,
"error" => "Couldn't get connection object.");
- Read upRead up
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 323.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
static function get_tags_for_event($event_id, $conn = null) {
$conn = $conn ?: Persistence::get_database_object();
$columns = array('id', 'title');
$table_name = 'tags';
$where = array(
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Postmortem {
- Exclude checks
Visibility must be declared on method "get_tags" Open
static function get_tags($conn = null) {
- Exclude checks
Method name "Postmortem::humanize_history" is not in camel caps format Open
static function humanize_history($history) {
- Exclude checks
Visibility must be declared on method "undelete_event" Open
static function undelete_event($event_id, $conn = null) {
- Exclude checks
Visibility must be declared on method "get_event_edit_status" Open
static function get_event_edit_status($event) {
- Exclude checks
Visibility must be declared on method "get_tags_for_event" Open
static function get_tags_for_event($event_id, $conn = null) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
} elseif( $row['deleted'] ) {
- Exclude checks
Method name "Postmortem::delete_tag" is not in camel caps format Open
static function delete_tag($tag_id, $event_id = null, $conn = null) {
- Exclude checks
Visibility must be declared on method "get_history" Open
static function get_history($event_id, $conn = null) {
- Exclude checks
Visibility must be declared on method "delete_event" Open
static function delete_event($event_id, $conn = null) {
- Exclude checks
Visibility must be declared on method "set_event_edit_status" Open
static function set_event_edit_status($id, $conn = null) {
- Exclude checks
Method name "Postmortem::get_tags" is not in camel caps format Open
static function get_tags($conn = null) {
- Exclude checks
Visibility must be declared on method "delete_tags_for_event" Open
static function delete_tags_for_event($event_id, $conn = null) {
- Exclude checks
Opening brace of a class must be on the line after the definition Open
class Postmortem {
- Exclude checks
Visibility must be declared on method "get_events_for_tags" Open
static function get_events_for_tags($tag_ids, $conn = null) {
- Exclude checks
Visibility must be declared on method "get_events_by_date" Open
static function get_events_by_date($start_date = null, $end_date = null, $conn = null) {
- Exclude checks
Method name "Postmortem::get_event" is not in camel caps format Open
static function get_event($event_id, $conn = null) {
- Exclude checks
Method name "Postmortem::delete_event" is not in camel caps format Open
static function delete_event($event_id, $conn = null) {
- Exclude checks
Visibility must be declared on method "undelete_tag" Open
static function undelete_tag($tag_id, $event_id = null, $conn = null) {
- Exclude checks
Visibility must be declared on method "add_history" Open
static function add_history($event, $admin, $action, $conn = null) {
- Exclude checks
Method name "Postmortem::save_event" is not in camel caps format Open
static function save_event($event, $conn = null) {
- Exclude checks
Method name "Postmortem::undelete_event" is not in camel caps format Open
static function undelete_event($event_id, $conn = null) {
- Exclude checks
Method name "Postmortem::get_events_for_tags" is not in camel caps format Open
static function get_events_for_tags($tag_ids, $conn = null) {
- Exclude checks
Visibility must be declared on method "get_history_event" Open
static function get_history_event($id, $conn = null) {
- Exclude checks
Method name "Postmortem::get_event_edit_status" is not in camel caps format Open
static function get_event_edit_status($event) {
- Exclude checks
Method name "Postmortem::get_all_events" is not in camel caps format Open
static function get_all_events($conn = null) {
- Exclude checks
Method name "Postmortem::delete_tags_for_event" is not in camel caps format Open
static function delete_tags_for_event($event_id, $conn = null) {
- Exclude checks
Visibility must be declared on method "save_tags_for_event" Open
static function save_tags_for_event($event_id, $tags, $conn = null) {
- Exclude checks
Visibility must be declared on method "get_event" Open
static function get_event($event_id, $conn = null) {
- Exclude checks
Method name "Postmortem::get_severity_levels" is not in camel caps format Open
static function get_severity_levels() {
- Exclude checks
Visibility must be declared on method "save_event" Open
static function save_event($event, $conn = null) {
- Exclude checks
Method name "Postmortem::set_event_edit_status" is not in camel caps format Open
static function set_event_edit_status($id, $conn = null) {
- Exclude checks
Visibility must be declared on method "get_all_events" Open
static function get_all_events($conn = null) {
- Exclude checks
Method name "Postmortem::save_tags_for_event" is not in camel caps format Open
static function save_tags_for_event($event_id, $tags, $conn = null) {
- Exclude checks
Visibility must be declared on method "delete_tag" Open
static function delete_tag($tag_id, $event_id = null, $conn = null) {
- Exclude checks
Method name "Postmortem::get_history_event" is not in camel caps format Open
static function get_history_event($id, $conn = null) {
- Exclude checks
Visibility must be declared on method "humanize_history" Open
static function humanize_history($history) {
- Exclude checks
Visibility must be declared on method "get_severity_levels" Open
static function get_severity_levels() {
- Exclude checks
Method name "Postmortem::get_tags_for_event" is not in camel caps format Open
static function get_tags_for_event($event_id, $conn = null) {
- Exclude checks
Method name "Postmortem::get_events_by_date" is not in camel caps format Open
static function get_events_by_date($start_date = null, $end_date = null, $conn = null) {
- Exclude checks
Blank line found at end of control structure Open
- Exclude checks
Method name "Postmortem::undelete_tag" is not in camel caps format Open
static function undelete_tag($tag_id, $event_id = null, $conn = null) {
- Exclude checks
Blank line found at end of control structure Open
- Exclude checks
Method name "Postmortem::add_history" is not in camel caps format Open
static function add_history($event, $admin, $action, $conn = null) {
- Exclude checks
Method name "Postmortem::get_history" is not in camel caps format Open
static function get_history($event_id, $conn = null) {
- Exclude checks
Opening brace should be on a new line Open
static function set_event_edit_status($id, $conn = null) {
- Exclude checks
Opening brace should be on a new line Open
static function get_history($event_id, $conn = null) {
- Exclude checks
Whitespace found at end of line Open
/**
- Exclude checks
Opening brace should be on a new line Open
static function get_events_by_date($start_date = null, $end_date = null, $conn = null) {
- Exclude checks
Expected 1 space after ELSEIF keyword; 0 found Open
} elseif( $row['deleted'] ) {
- Exclude checks
Opening brace should be on a new line Open
static function delete_event($event_id, $conn = null) {
- Exclude checks
Whitespace found at end of line Open
if (strcmp($user['username'], $event['modifier']) != 0) {
- Exclude checks
Opening brace should be on a new line Open
static function get_tags_for_event($event_id, $conn = null) {
- Exclude checks
Whitespace found at end of line Open
* @returns EDIT_UNLOCKED if editable, EDIT_LOCKED if a user is currently editing,
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
} elseif( $row['deleted'] ) {
- Exclude checks
Opening brace should be on a new line Open
static function get_tags($conn = null) {
- Exclude checks
Opening brace should be on a new line Open
static function get_severity_levels() {
- Exclude checks
Opening brace should be on a new line Open
static function delete_tags_for_event($event_id, $conn = null) {
- Exclude checks
Whitespace found at end of line Open
return array("status" => self::ERROR, "error" => $e->getMessage());
- Exclude checks
Opening brace should be on a new line Open
static function get_events_for_tags($tag_ids, $conn = null) {
- Exclude checks
Expected 1 space after CATCH keyword; 0 found Open
} catch(PDOException $e) {
- Exclude checks
Opening brace should be on a new line Open
static function save_event($event, $conn = null) {
- Exclude checks
Opening brace should be on a new line Open
static function undelete_tag($tag_id, $event_id = null, $conn = null) {
- Exclude checks
Opening brace should be on a new line Open
static function save_tags_for_event($event_id, $tags, $conn = null) {
- Exclude checks
Opening brace should be on a new line Open
static function humanize_history($history) {
- Exclude checks
Opening brace should be on a new line Open
static function undelete_event($event_id, $conn = null) {
- Exclude checks
Opening brace should be on a new line Open
static function get_all_events($conn = null) {
- Exclude checks
Opening brace should be on a new line Open
static function get_event($event_id, $conn = null) {
- Exclude checks
Opening brace should be on a new line Open
static function get_event_edit_status($event) {
- Exclude checks
Opening brace should be on a new line Open
static function delete_tag($tag_id, $event_id = null, $conn = null) {
- Exclude checks
Opening brace should be on a new line Open
static function get_history_event($id, $conn = null) {
- Exclude checks
Expected 1 space after CATCH keyword; 0 found Open
} catch(PDOException $e) {
- Exclude checks
Opening brace should be on a new line Open
static function add_history($event, $admin, $action, $conn = null) {
- Exclude checks