Function generateResultExtract
has a Cognitive Complexity of 147 (exceeds 5 allowed). Consider refactoring. Open
private function generateResultExtract($upload_id, $part_id, $voice, $startMeasure, $start, $endMeasure, $end) {
set_time_limit(300);
$upload = Upload::find($upload_id);
$doc = new DOMDocument();
- 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
Method generateResultExtract
has 188 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function generateResultExtract($upload_id, $part_id, $voice, $startMeasure, $start, $endMeasure, $end) {
set_time_limit(300);
$upload = Upload::find($upload_id);
$doc = new DOMDocument();
Function _getKey
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
public static function _getKey($id){
$xml = simplexml_load_string(Upload::find($id)->content);
$keys = $xml->xpath("//key");
$key = $keys[0];
- 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
File ResultController.php
has 345 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Controller to handle result requests
* Generating result extracts for search results
Function getDurationType
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function getDurationType($durationFloat) {
if ($durationFloat == 1){
return "whole";
} elseif ($durationFloat == 0.75) {
return "whole";
- 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
Method _getKey
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function _getKey($id){
$xml = simplexml_load_string(Upload::find($id)->content);
$keys = $xml->xpath("//key");
$key = $keys[0];
Method getDurationType
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getDurationType($durationFloat) {
if ($durationFloat == 1){
return "whole";
} elseif ($durationFloat == 0.75) {
return "whole";
Method generateResultExtract
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
private function generateResultExtract($upload_id, $part_id, $voice, $startMeasure, $start, $endMeasure, $end) {
Function getResultDetail
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getResultDetail($id, $page) {
if (Cache::has('results') && Cache::has('pattern')) {
$results = Cache::get('results');
foreach ($results as $item) {
if ($item->file_id == $id) {
- 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
Consider simplifying this complex logical expression. Open
if (($j == $startMeasure && $noteCounter >= $start) || ($j > $startMeasure && $j < $endMeasure) || ($j == $endMeasure && $noteCounter <= $end)) {
// set color to red if note is between start and end of result
$currentColor = "#b71c1c";
}
Avoid too many return
statements within this method. Open
return "16th";
Avoid too many return
statements within this method. Open
case "5": return "G sharp minor"; break;
Avoid too many return
statements within this method. Open
case "-5": return "D flat major"; break;
Avoid too many return
statements within this method. Open
case "-4": return "A flat major"; break;
Avoid too many return
statements within this method. Open
case "-1": return "D minor"; break;
Avoid too many return
statements within this method. Open
case "6": return "F sharp major"; break;
Avoid too many return
statements within this method. Open
case "-7": return "C flat major"; break;
Avoid too many return
statements within this method. Open
return "quarter";
Avoid too many return
statements within this method. Open
return "32nd";
Avoid too many return
statements within this method. Open
return "64th";
Avoid too many return
statements within this method. Open
return "64th"; // set to lowest possible value
Avoid too many return
statements within this method. Open
case "-2": return "B major"; break;
Avoid too many return
statements within this method. Open
case "1": return "E minor"; break;
Avoid too many return
statements within this method. Open
case "-2": return "G minor"; break;
Avoid too many return
statements within this method. Open
return "64th";
Avoid too many return
statements within this method. Open
case "-1": return "F major"; break;
Avoid too many return
statements within this method. Open
return "eighth";
Avoid too many return
statements within this method. Open
case "7": return "C sharp major"; break;
Avoid too many return
statements within this method. Open
case "-5": return "B minor"; break;
Avoid too many return
statements within this method. Open
case "3": return "F sharp minor"; break;
Avoid too many return
statements within this method. Open
case "0": return "A minor"; break;
Avoid too many return
statements within this method. Open
return "32nd";
Avoid too many return
statements within this method. Open
case "7": return "A sharp minor"; break;
Avoid too many return
statements within this method. Open
return "quarter";
Avoid too many return
statements within this method. Open
case "4": return "E major"; break;
Avoid too many return
statements within this method. Open
case "2": return "H minor"; break;
Avoid too many return
statements within this method. Open
case "4": return "C sharp minor"; break;
Avoid too many return
statements within this method. Open
case "6": return "D sharp minor"; break;
Avoid too many return
statements within this method. Open
case "-3": return "C minor"; break;
Avoid too many return
statements within this method. Open
case "-4": return "F minor"; break;
Avoid too many return
statements within this method. Open
case "-7": return "A flat minor"; break;
Avoid too many return
statements within this method. Open
case "-6": return "G flat major"; break;
Avoid too many return
statements within this method. Open
return "16th";
Avoid too many return
statements within this method. Open
case "-3": return "E flat major"; break;
Avoid too many return
statements within this method. Open
case "-6": return "E flat minor"; break;
Avoid too many return
statements within this method. Open
return "eighth";
Avoid too many return
statements within this method. Open
case "5": return "H major"; break;
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($pitch->length) {
// it's a note
$noteObject->type = "note";
$noteObject->pitch = new stdClass();
- 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 1038.
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
private function getDurationType($durationFloat) {
if ($durationFloat == 1){
return "whole";
} elseif ($durationFloat == 0.75) {
return "whole";
- 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 170.
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
if($fifths != null && $mode === "major"){
switch($fifths) {
case "0": return "C major"; break;
case "1": return "G major"; break;
case "2": return "D major"; break;
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
} elseif($fifths != null && $mode === "minor") {
switch($fifths) {
case "0": return "A minor"; break;
case "1": return "E minor"; break;
case "2": return "H minor"; break;
- 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