timgabets/electron-atm

View on GitHub

Showing 39 of 39 total issues

File atm.js has 761 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const StatesService = require('atm-states');
const ScreensService = require('atm-screens');
const FITsService = require('atm-fits');
const CryptoService = require('../services/crypto.js');
const DisplayService = require('../services/display.js');
Severity: Major
Found in src/controllers/atm.js - About 1 day to fix

ATM has 48 functions (exceeds 20 allowed). Consider refactoring.
Open

class ATM {
  constructor(settings, log){
    this.settings = settings;
    this.log = log;
    this.trace = new Trace();
Severity: Minor
Found in src/controllers/atm.js - About 6 hrs to fix

Function processNumericButtonPressed has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  processNumericButtonPressed(button){
    switch(this.current_state.get('type')){
    case 'B':
      this.PIN_buffer += button;
      if(this.PIN_buffer.length >= this.FITs.getMaxPINLength(this.card.number) || this.PIN_buffer.length >= 6 )
Severity: Minor
Found in src/controllers/atm.js - About 3 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 processState has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  processState(state_number){
    let state = this.states.get(state_number);
    let next_state = null;

    do{
Severity: Major
Found in src/controllers/atm.js - About 2 hrs to fix

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

      case 'Y':
        (state.get('extension_state') !== '255' && state.get('extension_state') !== '000') ? next_state = this.processStateY(state, this.states.get(state.get('extension_state'))) : next_state = this.processStateY(state);
        break;
Severity: Major
Found in src/controllers/atm.js and 1 other location - About 2 hrs to fix
src/controllers/atm.js on lines 803..805

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

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

      case 'X':
        (state.get('extension_state') !== '255' && state.get('extension_state') !== '000') ? next_state = this.processStateX(state, this.states.get(state.get('extension_state'))) : next_state = this.processStateX(state);
        break;
Severity: Major
Found in src/controllers/atm.js and 1 other location - About 2 hrs to fix
src/controllers/atm.js on lines 807..809

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

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

  processState(state_number){
    let state = this.states.get(state_number);
    let next_state = null;

    do{
Severity: Minor
Found in src/controllers/atm.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 processNumericButtonPressed has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  processNumericButtonPressed(button){
    switch(this.current_state.get('type')){
    case 'B':
      this.PIN_buffer += button;
      if(this.PIN_buffer.length >= this.FITs.getMaxPINLength(this.card.number) || this.PIN_buffer.length >= 6 )
Severity: Minor
Found in src/controllers/atm.js - About 1 hr to fix

Function processTransactionRequestState has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  processTransactionRequestState(state){
    this.display.setScreenByNumber(state.get('screen_number'));

    let request = {
      message_class: 'Unsolicited',
Severity: Minor
Found in src/controllers/atm.js - About 1 hr 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 setFDKsActiveMask has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  setFDKsActiveMask(mask){
    if(mask.length <= 3 && mask.length !== 0){
      // 1. mask is a number from 000 to 255, represented as string
      if(mask > 255){
        this.log.error('Invalid FDK mask: ' + mask);
Severity: Minor
Found in src/controllers/atm.js - About 1 hr 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 processTransactionRequestState has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  processTransactionRequestState(state){
    this.display.setScreenByNumber(state.get('screen_number'));

    let request = {
      message_class: 'Unsolicited',
Severity: Minor
Found in src/controllers/atm.js - About 1 hr to fix

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

        case '3': // Display data as keyed in. Store data in general-purpose Buffer B
          if(this.buffer_B.length < 32){
            this.buffer_B += button;

            buffer = this.buffer_B;
Severity: Major
Found in src/controllers/atm.js and 1 other location - About 1 hr to fix
src/controllers/atm.js on lines 1083..1092

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

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

        case '1': // Display data as keyed in. Store data in general-purpose Buffer C
          if(this.buffer_C.length < 32){
            this.buffer_C += button;

            buffer = this.buffer_C;
Severity: Major
Found in src/controllers/atm.js and 1 other location - About 1 hr to fix
src/controllers/atm.js on lines 1094..1103

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

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

  processBackspaceButtonPressed(){
    switch(this.current_state.get('type')){
    case 'B':
      this.PIN_buffer = this.PIN_buffer.slice(0, -1);
      this.display.insertText(this.PIN_buffer, '*');
Severity: Minor
Found in src/controllers/atm.js - About 1 hr to fix

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

  try:
    call(['mv', glob.glob('*.AppImage')[0], dest_dir + app_version + '/electron-atm-x86_64.AppImage'])
  except IndexError:
Severity: Major
Found in deploytool.py and 1 other location - About 1 hr to fix
deploytool.py on lines 61..63

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

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

  try:
    call(['mv', glob.glob('*.exe')[0], dest_dir + app_version + '/electron-atm-setup.exe'])
  except IndexError:
Severity: Major
Found in deploytool.py and 1 other location - About 1 hr to fix
deploytool.py on lines 56..58

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

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

  $('#show-new-card-form-button').on('click', function(){
    $('#add-new-card-form-area').show();
    $('#hide-new-card-button-area').show();
    $('#show-new-card-form-button').hide();
  });
Severity: Major
Found in src/listeners/cards.js and 1 other location - About 1 hr to fix
src/listeners/cards.js on lines 108..112

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

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

  $('#cancel-new-card-form-button').on('click', function(){
    $('#add-new-card-form-area').hide();
    $('#hide-new-card-button-area').hide();
    $('#show-new-card-form-button').show();
  });
Severity: Major
Found in src/listeners/cards.js and 1 other location - About 1 hr to fix
src/listeners/cards.js on lines 102..106

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

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

  processStateX(state, extension_state){
    this.display.setScreenByNumber(state.get('screen_number'));
    this.setFDKsActiveMask(state.get('FDK_active_mask'));

    let button = this.buttons_pressed.shift();
Severity: Minor
Found in src/controllers/atm.js - About 1 hr to fix

Function processFDKButtonPressed has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  processFDKButtonPressed(button){
    // log.info(button + ' button pressed');
    switch(this.current_state.get('type')){
    case 'B':
      if (button === 'A' && this.PIN_buffer.length >= 4)
Severity: Minor
Found in src/controllers/atm.js - About 1 hr to fix
Severity
Category
Status
Source
Language