Showing 6,675 of 6,675 total issues
Avoid deeply nested control flow statements. Open
if (item.host_approve_flag === 1) {
filtered.push(item);
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (!item.auto_renew && expiration < 0) {
filtered.push(item);
}
- Create a ticketCreate a ticket
Method saveFile
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function saveFile($id, $name, $fileName, $target_file, $type,
$fileLongType)
- Create a ticketCreate a ticket
Function handleSave
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
handleSave() {
this.setState({editMode: false});
var newStype = ReactDOM.findDOMNode(this.refs.savedStype).value.trim();
var newDescr = ReactDOM.findDOMNode(this.refs.savedDescr).value.trim();
- Read upRead up
- Create a ticketCreate a ticket
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 render
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
render() {
var ApproveData = null;
if (this.state.approveData != null && this.state.hostData != null && this.state.conditionData != null) {
ApproveData = this.state.approveData.map(function (host) {
return (
- Read upRead up
- Create a ticketCreate a ticket
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 __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(Internship $i, Student $student = null, SubHost $host, Supervisor $supervisor, Term $term, $studentExistingCreditHours)
- Create a ticketCreate a ticket
Method addColumn
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function addColumn($column, $max_min = null, $as = null, $count = false, $distinct = false, $coalesce = null)
- Create a ticketCreate a ticket
Function addColumn
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function addColumn($column, $max_min = null, $as = null, $count = false, $distinct = false, $coalesce = null)
{
/****
* What is this for?
- Read upRead up
- Create a ticketCreate a ticket
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 encodeStudents
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function encodeStudents(Array $students) {
$studentArray = array();
// If an empty array was given, just return an empty JSON array
if(sizeof($students) === 0){
- Read upRead up
- Create a ticketCreate a ticket
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 joinResult
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function joinResult($source_column, $join_table, $join_column, $content_column, $new_name=null, $searchable=false)
- Create a ticketCreate a ticket
Method addWhere
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function addWhere($column, $value = null, $operator = null, $conj = null, $group = null, $join = false)
- Create a ticketCreate a ticket
Function getStudent
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getStudent($studentId){
if($studentId === null || $studentId == ''){
throw new \InvalidArgumentException('Missing student ID.');
}
- Read upRead up
- Create a ticketCreate a ticket
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 __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(Internship $i = null, \PHPWS_User $phpwsUser = null, $timestamp = null, WorkflowState $fromState = null, WorkflowState $toState = null, $note = null)
- Create a ticketCreate a ticket
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(InternSettings $emailSettings, Internship $internship, Term $term, $censusTimestamp, $toUsername, $templateFile)
- Create a ticketCreate a ticket
Method addJoin
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function addJoin($join_type, $join_from, $join_to, $join_on_1 = null, $join_on_2 = null, $ignore_tables = false)
- Create a ticketCreate a ticket
Function checkRequiredFields
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function checkRequiredFields(Internship $i){
// Course number and subject are required so we can check against the expected insurance list in doNotification()
// NB: Course subject and number are not required for secondary parts of multi-part internships
if(!$i->isSecondaryPart() && $i->getCourseNumber() === null || $i->getCourseNumber() === ''){
throw new MissingDataException("Please enter a course number.");
- Read upRead up
- Create a ticketCreate a ticket
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 __construct
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(Internship $i = null, \PHPWS_User $phpwsUser = null, $timestamp = null, WorkflowState $fromState = null, WorkflowState $toState = null, $note = null)
{
if(!is_null($i)){
$this->id = 0;
$this->internship_id = $i->getId();
- Read upRead up
- Create a ticketCreate a ticket
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 requireClasses
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function requireClasses()
{
if ($this->load_class && is_array($this->load_class)) {
foreach ($this->load_class as $files) {
if (!is_array($files)) {
- Read upRead up
- Create a ticketCreate a ticket
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 prefixVary
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function prefixVary($sql, $tbl)
{
$repl = true;
$ar = explode("'", $sql);
- Read upRead up
- Create a ticketCreate a ticket
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
error: function(xhr, status, err){
alert("Failed to add department to database properly. "+ err.toString())
console.error(status, err.toString());
}
- Read upRead up
- Create a ticketCreate a ticket
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 50.
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