uccser/cs-field-guide

View on GitHub
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js

Summary

Maintainability
F
1 mo
Test Coverage

File mips-simulator.js has 759 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* Partial MIPS I Simulator based on the work of Alan Hogan
 * https://github.com/alanhogan/miphps-mips-simulator
 * Licensed under CC BY-NC-SA 4.0
 */

Severity: Major
Found in csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js - About 1 day to fix

Function run has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

function run() {
    SHOWCONTEXT = $('#show-context').is(':checked');
    SHOWREG = $('#show-registers').is(':checked');
    SHOWCOLOUR = $('#show-colours').is(':checked');
    PRINTTEXT = "";
Severity: Minor
Found in csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js - About 6 hrs 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 run has 103 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function run() {
    SHOWCONTEXT = $('#show-context').is(':checked');
    SHOWREG = $('#show-registers').is(':checked');
    SHOWCOLOUR = $('#show-colours').is(':checked');
    PRINTTEXT = "";
Severity: Major
Found in csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js - About 4 hrs to fix

Function interpret has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

function interpret(hex) {
    var name;
    var type;
    var arguments;
    var executables;
Severity: Minor
Found in csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js - About 2 hrs 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 operation has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function operation(type, opcode) {
    var returnCode;
    if (type == TYPE_R) {
        switch(opcode) {
            case(0):
Severity: Major
Found in csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js - About 2 hrs to fix

Function execute has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Function interpret has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function interpret(hex) {
    var name;
    var type;
    var arguments;
    var executables;
Severity: Major
Found in csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js - About 2 hrs to fix

Function operation has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function operation(type, opcode) {
    var returnCode;
    if (type == TYPE_R) {
        switch(opcode) {
            case(0):

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_syscall has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function execute_syscall (addr) {
    // syscall

    var a = REG_NAMES.indexOf("a0");
    var v = REG_NAMES.indexOf("v0");

Function execute_syscall has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function execute_syscall (addr) {
    // syscall

    var a = REG_NAMES.indexOf("a0");
    var v = REG_NAMES.indexOf("v0");
Severity: Minor
Found in csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js - About 55 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_bne has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function execute_bne (args, addr) {
    // bne $op1, $op2, [num instructions to skip]
        
    var op1 = args[1];
    var op2 = args[2];
Severity: Minor
Found in csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js - About 45 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_beq has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function execute_beq (args, addr) {
    // beq $op1, $op2, [num instructions to skip]
    
    var op1 = args[1];
    var op2 = args[2];
Severity: Minor
Found in csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js - About 45 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

Avoid too many return statements within this function.
Open

        return;
Severity: Major
Found in csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return [type, returnText, executables];
Severity: Major
Found in csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js - About 30 mins to fix

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

function interpretString(addr) {
    var returnText = "";
    var nextData = DATA[(addr - DATA_START) / 4];
    var lineHex = nextData[1];
    var chars = disect(lineHex);
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

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

function execute_beq (args, addr) {
    // beq $op1, $op2, [num instructions to skip]
    
    var op1 = args[1];
    var op2 = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 790..816

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

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

function execute_bne (args, addr) {
    // bne $op1, $op2, [num instructions to skip]
        
    var op1 = args[1];
    var op2 = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 758..784

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

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

function execute_addu (args, addr) {
    // addu $dest, $op1, $op2
        
    var dest = args[1];
    var op1 = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 550..570
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 602..622
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 628..648
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 654..674
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 680..700
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 706..726

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

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

function execute_sub (args, addr) {
    // sub $dest, $op1, $op2
    
    var dest = args[1];
    var op1 = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 550..570
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 576..596
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 628..648
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 654..674
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 680..700
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 706..726

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

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

function execute_or (args, addr) {
    // or $dest, $op1, $op2
        
    var dest = args[1];
    var op1 = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 550..570
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 576..596
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 602..622
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 628..648
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 654..674
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 706..726

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

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

function execute_add (args, addr) {
    // add $dest, $op1, $op2
    
    var dest = args[1];
    var op1 = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 576..596
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 602..622
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 628..648
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 654..674
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 680..700
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 706..726

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

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

function execute_and (args, addr) {
    // and $dest, $op1, $op2
        
    var dest = args[1];
    var op1 = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 550..570
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 576..596
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 602..622
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 628..648
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 680..700
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 706..726

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

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

function execute_subu (args, addr) {
    // subu $dest, $op1, $op2
    
    var dest = args[1];
    var op1 = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 550..570
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 576..596
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 602..622
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 654..674
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 680..700
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 706..726

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

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

function execute_xor (args, addr) {
    // xor $dest, $op1, $op2
        
    var dest = args[1];
    var op1 = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 550..570
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 576..596
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 602..622
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 628..648
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 654..674
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 680..700

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

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 5 locations. Consider refactoring.
Open

function execute_andi (args, addr) {
    // andi $dest, $operand, imm

    var dest = args[1];
    var op = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 510..526
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 848..864
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 892..908
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 914..930

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

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 5 locations. Consider refactoring.
Open

function execute_xori (args, addr) {
    // xori $dest, $operand, imm

    var dest = args[1];
    var op = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 510..526
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 848..864
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 870..886
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 892..908

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

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 5 locations. Consider refactoring.
Open

function execute_sll (args, addr) {
    // sll $dest, $op1, shift
    
    var dest = args[1];
    var op = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 848..864
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 870..886
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 892..908
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 914..930

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

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 5 locations. Consider refactoring.
Open

function execute_ori (args, addr) {
    // ori $dest, $operand, imm

    var dest = args[1];
    var op = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 510..526
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 848..864
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 870..886
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 914..930

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

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 5 locations. Consider refactoring.
Open

function execute_addiu (args, addr) {
    // addiu $dest, $operand, imm

    var dest = args[1];
    var op = args[2];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 510..526
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 870..886
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 892..908
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 914..930

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

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

            if (SHOWCONTEXT) {
                PRINTTEXT += TXT_LOAD + " " + colour(hexOfInt(instrAddr, 8), COLOUR_ADDR) + " : " + colour(hexOfInt(instrHex, 8), COLOUR_INSTR) + "; |" + colour(TXT_INSTRUCTION + ":" + instrIndex, COLOUR_INPUT) + "| " + colour("syscall", COLOUR_INSTR) + "<br>";
            }
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 196..198

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

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

                if (SHOWCONTEXT) {
                    PRINTTEXT += TXT_LOAD + " " + colour(hexOfInt(instrAddr, 8), COLOUR_ADDR) + " : " + colour(hexOfInt(instrHex, 8), COLOUR_INSTR) + "; |" + colour(TXT_INSTRUCTION + ":" + instrIndex, COLOUR_INPUT) + "| " + colour("jr $ra", COLOUR_INSTR) + "<br>";
                }
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 184..186

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

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

        if (name == "sll") {
            // Interpret as the supported shift operation
            // sll $dest, $operand, shift
            executables = [name, arguments[3], arguments[2], arguments[4]];
            returnText = name + " $" + REG_NAMES[executables[1]] + ", $" + REG_NAMES[executables[2]] + ", " + executables[3];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 393..403

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

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

        if (name == "beq" || name == "bne") {
            // Interpret as one of the supported branch operations
            // name $operand1, $operand2, [num instructions skipped]
            executables = [name, arguments[1], arguments[2], arguments[3]];
            returnText = name + " $" + REG_NAMES[executables[1]] + ", $" + REG_NAMES[executables[2]] + ", " + executables[3];
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 358..373

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

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 3 locations. Consider refactoring.
Open

function hexOfInt(num, n) {
    var returnString = num.toString(16);
    if (returnString.length < n) {
        return "0".repeat(n - returnString.length) + returnString;
    } else {
csfieldguide/static/interactives/mips-assembler/js/mips-assembler.js on lines 450..457
csfieldguide/static/interactives/mips-assembler/js/mips-assembler.js on lines 489..496

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

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

    if (REGISTERS[a] === null || isNaN(REGISTERS[a])) {
        PRINTTEXT += colour(TXT_NOREAD + ": $a0", COLOUR_BAD) + " <br>";
        return -1;
    }
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 957..960

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

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

    if (REGISTERS[v] === null || isNaN(REGISTERS[v])) {
        PRINTTEXT += colour(TXT_NOREAD + ": $v0", COLOUR_BAD) + " <br>";
        return -1;
    }
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 953..956

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

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 4 locations. Consider refactoring.
Open

    $('#reset-basic').on('click', function () {
        $('#assembled-input').val(basicProgram);
        $('#program-output').html('');
    });
csfieldguide/static/interactives/mips-assembler/js/mips-assembler.js on lines 56..59
csfieldguide/static/interactives/mips-assembler/js/mips-assembler.js on lines 61..64
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 86..89

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

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 4 locations. Consider refactoring.
Open

    $('#reset-adv').on('click', function () {
        $('#assembled-input').val(advancedProgram);
        $('#program-output').html('');
    });
csfieldguide/static/interactives/mips-assembler/js/mips-assembler.js on lines 56..59
csfieldguide/static/interactives/mips-assembler/js/mips-assembler.js on lines 61..64
csfieldguide/static/interactives/mips-simulator/js/mips-simulator.js on lines 81..84

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

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

function colour(text, colour) {
    if (SHOWCOLOUR) {
        return '<span style="color:' + colour + '">' + text + '</span>';
    } else {
        return text;
csfieldguide/static/interactives/mips-assembler/js/mips-assembler.js on lines 361..367

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

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

There are no issues that match your filters.

Category
Status