Showing 76 of 76 total issues
Function toNewEval
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function toNewEval(evaluations) {
let newEval = {};
for (const evaluation in evaluations) {
for (const exam in evaluations[evaluation].exams) {
if (!newEval[exam]) newEval[exam] = {};
- 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 confetti
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
window.confetti = function (root)
- 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 deeply nested control flow statements. Open
if (
subjects[id].necesaryMarks[evaluation][exam] !== undefined &&
subjects[id].necesaryMarks[evaluation][exam] <
identifiers.types[type].value
) {
Avoid deeply nested control flow statements. Open
if (!subjects[id]) subjects[id] = {};
Function displayNecesaryMark
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function displayNecesaryMark(id) {
let card = getCard(id);
let barUndone = card.getElementsByClassName('scolN');
let inUndone = card.getElementsByClassName('scolN2');
- 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 toNewEvalNeeeeeeeeew
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function toNewEvalNeeeeeeeeew(evaluations) {
var evaluationNew = {};
for (let evaluation in evaluations) {
if (evaluations[evaluation].exams) return evaluations;
evaluationNew[evaluation] = {};
- 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 uploadToDB
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function uploadToDB(db, ref, value) {
if (!isAnonymous) {
let obj = {};
if (ref) {
if (
- 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 generateBar
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function generateBar(id) {
let weight = 0;
let barHTML = '';
for (const exam in subjects[id].evaluations[subjects[id].selectedEvaluation]
.exams) {
- 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 updateFinalMark
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function updateFinalMark(id, confetti = true) {
for (const evaluation in subjects[id].evaluations) {
subjects[id].finalMark[evaluation] = 0;
for (const exam in subjects[id].evaluations[evaluation].exams) {
if (!isUndone(id, exam))
- 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 deeply nested control flow statements. Open
if (canPass === false) {
subjects[id].necesaryMarks[evaluation][exam] = null;
} else {
subjects[id].necesaryMarks[evaluation][exam] = Math.max(
0,
Avoid deeply nested control flow statements. Open
if (exam && examType && weight) {
if (!newEval[evaluation]) newEval[evaluation] = {};
if (!newEval[evaluation].exams) newEval[evaluation].exams = {};
if (!newEval[evaluation].exams[exam])
newEval[evaluation].exams[exam] = {};
Avoid deeply nested control flow statements. Open
if (!userInfo.subjects[id]) userInfo.subjects[id] = {};
Function addSubjects
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function addSubjects() {
showLoader('Cargando tus asignaturas', 'dashboard');
document.getElementById('search-subject-input').value = '';
for (let id in subjectsToAdd) {
- 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 findIdentifiersTree
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function findIdentifiersTree(tree, identifiers, types, id, evaluation) {
Function completeSubject
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function completeSubject(...subjects) {
let subject = Object.assign(
{
evaluations: {},
grades: {},
- 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 editGridFadeOrUnfade
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function editGridFadeOrUnfade(grid, element, check = ['exam', 'evaluation']) {
for (const type of check) {
if (
element.dataset[type] != undefined &&
parseInt(element.dataset[type]) < parseInt(grid.dataset[type + 's'])
- 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 saveEditSubject
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function saveEditSubject() {
let newSubject = readSubjectFromPopup(editSubjectPopup);
let id = newSubject.id;
if (newSubject.shortName != subjects[id].shortName)
- 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 findIdentifiersTree
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function findIdentifiersTree(tree, identifiers, types, id, evaluation) {
switch (tree.type) {
case 'LogicalExpression':
case 'BinaryExpression':
if (
- 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 function. Open
return true;
Similar blocks of code found in 3 locations. Consider refactoring. Open
appendElement(
grid,
`<input style="grid-row: ${
2 + parseInt(grid.dataset.exams)
}; grid-column: 2;" class="edit-new-exam" type="text" name="examType" value="" data-exam="${
- 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 45.
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