timgabets/electron-atm

View on GitHub

Showing 24 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

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

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

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

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

  getPaymentScheme(cardnumber){
    if(cardnumber[0] === '4')
      return 'VISA';

    switch(cardnumber.substr(0, 2)){
Severity: Minor
Found in src/services/cards.js - About 1 hr to fix

Function buildFITsList has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function buildFITsList(){
    fits.get().forEach( (fit) => {
      fit_record = '<tr>';

      fit_record += '<td>'
Severity: Minor
Found in src/listeners/fits.js - About 1 hr to fix

Function processCustomizationCommand has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  processCustomizationCommand(data){
    switch(data.message_identifier){
    case 'Screen Data load':
      if(this.screens.add(data.screens))
        return this.replySolicitedStatus('Ready'); 
Severity: Minor
Found in src/controllers/atm.js - About 1 hr to fix

Function processInformationEntryState has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  processInformationEntryState(state){
    this.display.setScreenByNumber(state.get('screen_number'));
    let active_mask = '0';
    [ state.get('FDK_A_next_state'),
      state.get('FDK_B_next_state'),
Severity: Minor
Found in src/controllers/atm.js - About 1 hr to fix

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

  processCustomizationCommand(data){
    switch(data.message_identifier){
    case 'Screen Data load':
      if(this.screens.add(data.screens))
        return this.replySolicitedStatus('Ready'); 
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 getTerminalStateReply has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getTerminalStateReply(command_code){
    let reply = {};

    if(command_code)
      reply.terminal_command = command_code;
Severity: Minor
Found in src/controllers/atm.js - About 1 hr to fix

Function processStateX has a Cognitive Complexity of 9 (exceeds 5 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 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

Avoid too many return statements within this function.
Open

        return this.replySolicitedStatus('Ready');
Severity: Major
Found in src/controllers/atm.js - About 30 mins to fix
Severity
Category
Status
Source
Language