Function calcStudentGrade
has a Cognitive Complexity of 288 (exceeds 5 allowed). Consider refactoring. Open
public function calcStudentGrade(
TblPerson $tblPerson,
TblDivision $tblDivision,
TblSubject $tblSubject,
TblTestType $tblTestType,
- 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 Service.php
has 1429 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace SPHERE\Application\Education\Graduation\Gradebook;
use SPHERE\Application\Education\Certificate\Generator\Generator;
Function getScoreConditionByStudent
has a Cognitive Complexity of 183 (exceeds 5 allowed). Consider refactoring. Open
public function getScoreConditionByStudent(
TblScoreRule $tblScoreRule,
$tblGradeList,
TblYear $tblYear = null,
TblPeriod $tblPeriod = null,
- 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 updateGradeToTest
has a Cognitive Complexity of 126 (exceeds 5 allowed). Consider refactoring. Open
public function updateGradeToTest(
IFormInterface $Stage = null,
$TestId = null,
$Grade = null,
$BasicRoute,
- 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 calcStudentGrade
has 241 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function calcStudentGrade(
TblPerson $tblPerson,
TblDivision $tblDivision,
TblSubject $tblSubject,
TblTestType $tblTestType,
Method updateGradeToTest
has 241 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateGradeToTest(
IFormInterface $Stage = null,
$TestId = null,
$Grade = null,
$BasicRoute,
Function updateScoreTypeDivisionSubject
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
public function updateScoreTypeDivisionSubject(
IFormInterface $Stage = null,
TblScoreType $tblScoreType,
TblYear $tblYear = null,
$Data = null
- 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 filterDivisionSubjectList
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
public function filterDivisionSubjectList(
$tblDivisionSubjectList,
TblYear $filterYear = null,
TblType $filterType = null,
TblLevel $filterLevel = null
- 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
Service
has 49 functions (exceeds 20 allowed). Consider refactoring. Open
class Service extends ServiceScoreRule
{
/**
* @param bool $doSimulation
Function getAverageByTest
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
public function getAverageByTest(TblTest $tblTest, &$gradeMirror = array())
{
$tblDivision = $tblTest->getServiceTblDivision();
$tblSubject = $tblTest->getServiceTblSubject();
- 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 updateProposalBehaviorGrade
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
public function updateProposalBehaviorGrade(
IFormInterface $form,
TblDivision $tblDivision,
TblTask $tblTask,
TblGradeType $tblGradeType,
- 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 getScoreConditionByStudent
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getScoreConditionByStudent(
TblScoreRule $tblScoreRule,
$tblGradeList,
TblYear $tblYear = null,
TblPeriod $tblPeriod = null,
Function sortGradeList
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function sortGradeList($tblGradeList)
{
if (($tblSetting = Consumer::useService()->getSetting(
'Education', 'Graduation', 'Gradebook', 'SortHighlighted'
- 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 updateProposalBehaviorGrade
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateProposalBehaviorGrade(
IFormInterface $form,
TblDivision $tblDivision,
TblTask $tblTask,
TblGradeType $tblGradeType,
Method filterDivisionSubjectList
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function filterDivisionSubjectList(
$tblDivisionSubjectList,
TblYear $filterYear = null,
TblType $filterType = null,
TblLevel $filterLevel = null
Method updateScoreTypeDivisionSubject
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateScoreTypeDivisionSubject(
IFormInterface $Stage = null,
TblScoreType $tblScoreType,
TblYear $tblYear = null,
$Data = null
Function getGradesAllByStudentAndYearAndSubject
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function getGradesAllByStudentAndYearAndSubject(
TblPerson $tblPerson,
TblYear $tblYear,
TblSubject $tblSubject,
TblTestType $tblTestType,
- 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 getGradesFromAnotherDivisionByStudent
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function getGradesFromAnotherDivisionByStudent(
TblDivision $tblDivision,
TblSubject $tblSubject,
TblYear $tblYear,
TblPerson $tblPerson,
- 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 sortGradeList
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sortGradeList($tblGradeList)
{
if (($tblSetting = Consumer::useService()->getSetting(
'Education', 'Graduation', 'Gradebook', 'SortHighlighted'
Method getAverageByTest
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAverageByTest(TblTest $tblTest, &$gradeMirror = array())
{
$tblDivision = $tblTest->getServiceTblDivision();
$tblSubject = $tblTest->getServiceTblSubject();
Method setDisableParent
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setDisableParent(
IFormInterface $Form,
$ParentAccount,
$tblAccountStudent
) {
Method updateGradeType
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateGradeType(IFormInterface $Stage = null, $Id, $GradeType)
{
/**
* Skip to Frontend
Method calcStudentGrade
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
TblPerson $tblPerson,
TblDivision $tblDivision,
TblSubject $tblSubject,
TblTestType $tblTestType,
TblScoreRule $tblScoreRule = null,
Method createGradeType
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createGradeType(IFormInterface $Stage = null, $GradeType)
{
/**
* Skip to Frontend
Method getGradesFromAnotherDivisionByStudent
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getGradesFromAnotherDivisionByStudent(
TblDivision $tblDivision,
TblSubject $tblSubject,
TblYear $tblYear,
TblPerson $tblPerson,
Function setDisableParent
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function setDisableParent(
IFormInterface $Form,
$ParentAccount,
$tblAccountStudent
) {
- 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 ($tblDivisionStudentItem->getLeaveDateTime() !== null
&& $tblDivisionStudentItem->getUseGradesInNewDivision()
&& ($tblDivisionItem = $tblDivisionStudentItem->getTblDivision())
&& $tblDivision->getId() != $tblDivisionItem->getId()
&& ($tblYearItem = $tblDivisionItem->getServiceTblYear())
Method isEditGrade
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
private function isEditGrade(TblGrade $tblGrade, $Comment, $grade, $trend, $date, $text, $publicComment)
Method updateGradeToTest
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
IFormInterface $Stage = null,
$TestId = null,
$Grade = null,
$BasicRoute,
TblScoreType $tblScoreType = null,
Method updateProposalBehaviorGrade
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
IFormInterface $form,
TblDivision $tblDivision,
TblTask $tblTask,
TblGradeType $tblGradeType,
$Grade,
Method getGradesFromAnotherDivisionByStudent
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
TblDivision $tblDivision,
TblSubject $tblSubject,
TblYear $tblYear,
TblPerson $tblPerson,
TblTestType $tblTestType,
Method getGradesByStudent
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
TblPerson $tblPerson,
TblDivision $tblDivision,
TblSubject $tblSubject,
TblTestType $tblTestType,
TblPeriod $tblPeriod = null,
Avoid deeply nested control flow statements. Open
if (($tblGrade = $this->getGradeById($gradeId))) {
$tblGradeList[] = $tblGrade;
}
Avoid deeply nested control flow statements. Open
if (($tblScoreGroup = $tblScoreConditionGroupRequirement->getTblScoreGroup())
&& ($tblGradeTypeList = Gradebook::useService()->getScoreGroupGradeTypeListByGroup($tblScoreGroup))
) {
$gradeTypeList = array();
foreach ($tblGradeTypeList as $tblGradeTypeItem) {
Avoid deeply nested control flow statements. Open
if ($tblGrade->getGrade() !== null && $tblGrade->getGrade() !== '' && is_numeric($tblGrade->getGrade())) {
// für Teilnoten Extra-Liste
if (($tblGradeType = $tblGrade->getTblGradeType())
&& $tblGradeType->isPartGrade()
) {
Avoid deeply nested control flow statements. Open
if (($tblPeriodList = Term::useService()->getPeriodAllByYear($tblYear, $isLevel12))) {
$firstPeriod = reset($tblPeriodList);
if ($period == TblScoreCondition::PERIOD_FIRST_PERIOD) {
if ($tblPeriod && $firstPeriod->getId() == $tblPeriod->getId()) {
Avoid deeply nested control flow statements. Open
if (isset($group['Value']) && isset($group['Multiplier'])) {
$totalMultiplier += $multiplier;
$average += $multiplier * ($group['Value'] / $group['Multiplier']);
}
Avoid deeply nested control flow statements. Open
if (($tblGradeType = $tblScoreConditionGradeTypeList->getTblGradeType())) {
/** @var TblGrade $tblGrade */
foreach ($tblGradeList as $tblGrade) {
if (is_numeric($tblGrade->getGrade())
&& $tblGrade->getTblGradeType()
Avoid deeply nested control flow statements. Open
if ($hasMirror) {
$value = intval(round($value, 0));
$gradeMirror[$value]++;
}
Avoid deeply nested control flow statements. Open
if (isset($itemValue['Value']) && isset($itemValue['Multiplier'])) {
$totalMultiplier += $multiplier;
$average += $multiplier * ($itemValue['Value'] / $itemValue['Multiplier']);
}
Avoid deeply nested control flow statements. Open
if (($tblTask = $tblTest->getTblTask()) && !$tblTask->isLocked()) {
Evaluation::useService()->setTaskLocked($tblTask);
}
Consider simplifying this complex logical expression. Open
if ($filterYear && $filterLevel && $filterType) {
if ($hasYear && $hasLevel && $hasType) {
array_push($resultList, $tblDivisionSubject);
}
} elseif ($filterYear && $filterLevel) {
Consider simplifying this complex logical expression. Open
if ($tblGradeItem && $gradeValue === ''
&& !isset($value['Attendance'])
&& (!isset($value['Text']) || (isset($value['Text']) && !$this->getGradeTextById($value['Text'])))
) {
$errorNoGrade[] = new Container(new Bold($tblPerson->getLastFirstName()));
Method getScoreConditionByStudent
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
TblScoreRule $tblScoreRule,
$tblGradeList,
TblYear $tblYear = null,
TblPeriod $tblPeriod = null,
$isLevel12 = false
Method getGradesAllByStudentAndYearAndSubject
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
TblPerson $tblPerson,
TblYear $tblYear,
TblSubject $tblSubject,
TblTestType $tblTestType,
TblPeriod $tblPeriod = null
Function updateGradeType
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function updateGradeType(IFormInterface $Stage = null, $Id, $GradeType)
{
/**
* Skip to Frontend
- 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
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Function createGradeType
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function createGradeType(IFormInterface $Stage = null, $GradeType)
{
/**
* Skip to Frontend
- 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 isEditGrade
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function isEditGrade(TblGrade $tblGrade, $Comment, $grade, $trend, $date, $text, $publicComment)
{
$isChange = false;
if($tblGrade->getComment() != $Comment){
$isChange = true;
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!empty($Grade)
&& $tblScoreType
&& $tblScoreType->getPattern() !== ''
) {
foreach ($Grade as $personId => $value) {
- 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 168.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!empty($Grade)
&& $tblScoreType
&& $tblScoreType->getPattern() !== ''
) {
foreach ($Grade as $personId => $value) {
- 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 168.
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 (is_array($Data)) {
foreach ($Data as $divisionId => $subjectList) {
$tblDivision = Division::useService()->getDivisionById($divisionId);
if ($tblDivision) {
if (is_array($subjectList)) {
- 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 158.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($grade != -1) {
if (isset($value['Trend'])) {
$trend = $value['Trend'];
} elseif ((strpos($grade, '+') !== false)) {
$trend = TblGrade::VALUE_TREND_PLUS;
- 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 135.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($grade != -1) {
if (isset($value['Trend'])) {
$trend = $value['Trend'];
} elseif ((strpos($grade, '+') !== false)) {
$trend = TblGrade::VALUE_TREND_PLUS;
- 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 135.
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 3 locations. Consider refactoring. Open
public function getGradesByStudent(
TblPerson $tblPerson,
TblDivision $tblDivision,
TblSubject $tblSubject,
TblTestType $tblTestType,
- 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 90.
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