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');
- Create a ticketCreate a ticket
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();
- Create a ticketCreate a ticket
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 )
- Read upRead up
- Create a ticketCreate a ticket
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{
- Create a ticketCreate a ticket
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{
- Read upRead up
- Create a ticketCreate a ticket
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 )
- Create a ticketCreate a ticket
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',
- Read upRead up
- Create a ticketCreate a ticket
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);
- Read upRead up
- Create a ticketCreate a ticket
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',
- Create a ticketCreate a ticket
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, '*');
- Create a ticketCreate a ticket
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();
- Create a ticketCreate a ticket
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)
- Create a ticketCreate a ticket
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)){
- Create a ticketCreate a ticket
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>'
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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'),
- Create a ticketCreate a ticket
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');
- Read upRead up
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
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();
- Read upRead up
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket