uccser/cs-field-guide

View on GitHub

Showing 876 of 876 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            level = Math.max(Math.min(level, self.options.maxZoom), self.options.minZoom);
csfieldguide/static/interactives/pixel-viewer/js/third-party/Scroller.js on lines 788..788

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

    operations = [
        migrations.AlterField(
            model_name='interactive',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 13..16
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 18..21
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 23..26
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 28..31
csfieldguide/curriculum_guides/migrations/0006_auto_20220131_0002.py on lines 13..16
csfieldguide/curriculum_guides/migrations/0006_auto_20220131_0002.py on lines 18..21

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 32.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

Severity: Minor
Found in csfieldguide/chapters/migrations/0019_merge_20180316_0511.py and 1 other location - About 30 mins to fix
csfieldguide/chapters/migrations/0008_merge_20171204_0325.py on lines 0..15

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 32.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

var matrix_rotate_scale_translate_2 = {
    "type":     "matrix",
    "title":    gettext("Multiple Transformation Challenge"),
    "task":     gettext("Try moving the shape to the target position by using the two multiplication matrices (one to scale and one to rotate) then translating."),
    "target":   "-11.1 -6.08 -8.26 -8.92 -5.42 -6.08 -1.16 -16.02 1.68 -13.18 -2.58 -3.24 -5.42 -0.4",
csfieldguide/static/interactives/2d-shape-manipulations/js/2d-shape-manipulations.js on lines 42..48

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            this.collapsable = nodeStructure.collapsable === false ? false : (nodeStructure.collapsable || tree.CONFIG.node.collapsable);
csfieldguide/static/interactives/tree-diagram/js/third-party/Treant.js on lines 1352..1352

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

        migrations.AlterField(
            model_name='chaptersection',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
Severity: Major
Found in csfieldguide/chapters/migrations/0034_auto_20220131_0002.py and 6 other locations - About 30 mins to fix
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 13..16
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 23..26
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 28..31
csfieldguide/curriculum_guides/migrations/0006_auto_20220131_0002.py on lines 13..16
csfieldguide/curriculum_guides/migrations/0006_auto_20220131_0002.py on lines 18..21
csfieldguide/interactives/migrations/0018_alter_interactive_id.py on lines 12..16

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 32.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

        migrations.AlterField(
            model_name='glossaryterm',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
Severity: Major
Found in csfieldguide/chapters/migrations/0034_auto_20220131_0002.py and 6 other locations - About 30 mins to fix
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 13..16
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 18..21
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 23..26
csfieldguide/curriculum_guides/migrations/0006_auto_20220131_0002.py on lines 13..16
csfieldguide/curriculum_guides/migrations/0006_auto_20220131_0002.py on lines 18..21
csfieldguide/interactives/migrations/0018_alter_interactive_id.py on lines 12..16

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 32.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

        migrations.AlterField(
            model_name='chaptersectionheading',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
Severity: Major
Found in csfieldguide/chapters/migrations/0034_auto_20220131_0002.py and 6 other locations - About 30 mins to fix
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 13..16
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 18..21
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 28..31
csfieldguide/curriculum_guides/migrations/0006_auto_20220131_0002.py on lines 13..16
csfieldguide/curriculum_guides/migrations/0006_auto_20220131_0002.py on lines 18..21
csfieldguide/interactives/migrations/0018_alter_interactive_id.py on lines 12..16

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 32.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

        migrations.AlterField(
            model_name='chapter',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
Severity: Major
Found in csfieldguide/chapters/migrations/0034_auto_20220131_0002.py and 6 other locations - About 30 mins to fix
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 18..21
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 23..26
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 28..31
csfieldguide/curriculum_guides/migrations/0006_auto_20220131_0002.py on lines 13..16
csfieldguide/curriculum_guides/migrations/0006_auto_20220131_0002.py on lines 18..21
csfieldguide/interactives/migrations/0018_alter_interactive_id.py on lines 12..16

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 32.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

var matrix_rotate_scale_translate = {
    "type":     "matrix",
    "title":    gettext("Combining Translation, Scaling and Rotation"),
    "task":     gettext("Try moving the shape to the target position by using the two multiplication matrices (one to scale and one to rotate) then translating."),
    "target":   "11 8 9 8 9 4 4 8 4 4 9 0 11 0",
csfieldguide/static/interactives/2d-shape-manipulations/js/2d-shape-manipulations.js on lines 50..56

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                    level = Math.max(Math.min(level, self.options.maxZoom), self.options.minZoom);
csfieldguide/static/interactives/pixel-viewer/js/third-party/Scroller.js on lines 475..475

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

        migrations.AlterField(
            model_name='curriculumguidesection',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 13..16
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 18..21
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 23..26
csfieldguide/chapters/migrations/0034_auto_20220131_0002.py on lines 28..31
csfieldguide/curriculum_guides/migrations/0006_auto_20220131_0002.py on lines 13..16
csfieldguide/interactives/migrations/0018_alter_interactive_id.py on lines 12..16

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 32.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                {
                    relevantWidgets: [],
                    isSatisfied: function() {
                        return true;
                    },
csfieldguide/static/interactives/plane-turbulence/js/plane-turbulence.js on lines 416..425

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

Further Reading

Function stage1check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function stage1check(button) {
  var destination = document.getElementById("destinationIP").innerHTML;
  if (destination == validDestinationIP && button == "allow") {
    animation("Accept")
    return true;
Severity: Minor
Found in csfieldguide/static/interactives/firewall-sorting/js/firewall-sorting.js - About 25 mins to fix

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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function execute(type, args, addr) {
    var nextAddr;
    var opcode;
    if (type == TYPE_SYSCALL) {
        if (execute_syscall() < 0) {
Severity: Minor
Found in csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js - About 25 mins to fix

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 getUrlParameter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    getUrlParameter: function(sParam) {
        var sPageURL = decodeURIComponent(window.location.search.substring(1)),
            sURLVariables = sPageURL.split("&"),
            sParameterName,
            i;
Severity: Minor
Found in csfieldguide/static/js/third-party/url-parameters.js - About 25 mins to fix

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 fillMatrices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function fillMatrices(isReset) {
    var transform = screenObjectTransforms[suspect.name][0];
    if (transform != null && !isReset) {
        // Transform to be added
        $('#matrix-row-0-col-0').val(transform[0][0]);
Severity: Minor
Found in csfieldguide/static/interactives/scene-editor/js/scene-editor.js - About 25 mins to fix

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 choosePort has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function choosePort(score, P) {
  if (Math.random() > P) {
    document.getElementById("sourcePort").innerHTML = validSourcePort;
  }
  else {
Severity: Minor
Found in csfieldguide/static/interactives/firewall-sorting/js/firewall-sorting.js - About 25 mins to fix

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 stage2check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function stage2check(button) {
  var destination = document.getElementById("destinationIP").innerHTML;
  var source = document.getElementById("sourceIP").innerHTML;
  if (destination == validDestinationIP && source == validSourceIP && button == 'allow') {
    animation("Accept")
Severity: Minor
Found in csfieldguide/static/interactives/firewall-sorting/js/firewall-sorting.js - About 25 mins to fix

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 autoTab has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function autoTab(event) {
    var placeholder_element = event.srcElement;

    if (placeholder_element.value.length == placeholder_element.maxLength) {
        var placeholder_index = parseInt(placeholder_element.dataset.index);
Severity: Minor
Found in csfieldguide/static/interactives/lzss-compression/js/lzss-compression.js - About 25 mins to fix

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

Severity
Category
Status
Source
Language