lgaticaq/cellocator-parser

View on GitHub

Showing 7 of 29 total issues

Function exports has 890 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (transmissionReason, transmissionReasonSpecificData) => {
  const tx = core.convertBase(transmissionReason, 16, 10);
  const txDataDec = core.convertBase(transmissionReasonSpecificData, 16, 10);
  const txDataBin = core.hex2bin(transmissionReasonSpecificData);
  let alarm = {};
Severity: Major
Found in src/alarms.js - About 4 days to fix

    File alarms.js has 894 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    const core = require('./core');
    
    module.exports = (transmissionReason, transmissionReasonSpecificData) => {
    Severity: Major
    Found in src/alarms.js - About 2 days to fix

      Function exports has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = (transmissionReason, transmissionReasonSpecificData) => {
        const tx = core.convertBase(transmissionReason, 16, 10);
        const txDataDec = core.convertBase(transmissionReasonSpecificData, 16, 10);
        const txDataBin = core.hex2bin(transmissionReasonSpecificData);
        let alarm = {};
      Severity: Minor
      Found in src/alarms.js - About 1 day 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

      File utils.js has 322 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      
      const hardwares = require('./hardwares');
      const core = require('./core');
      const parseAlarm = require('./alarms');
      Severity: Minor
      Found in src/utils.js - About 3 hrs to fix

        Function getData has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const getData = raw => {
          const bytes = raw.toString('hex').split(/([A-F0-9]{2})/i).filter(x => x !== '');
          const seconds = bytes[62];
          const io = parseIO(bytes.slice(20, 24).join(''));
          const unitsStatusCurrentGsmOperator = parseUnitsStatusCurrentGsmOperator(bytes[15]);
        Severity: Major
        Found in src/utils.js - About 2 hrs to fix

          Function parse has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          const parse = raw => {
            const rawString = raw.toString('hex');
            if (!utils.patterns.data.test(rawString)) return {type: 'UNKNOWN', raw: rawString};
            const results = rawString.split(utils.patterns.multi).filter(x => utils.patterns.data.test(x)).map(utils.getData);
            const incompleteData = rawString.split(utils.patterns.multi).filter(x => !utils.patterns.data.test(x) && x !== '');
          Severity: Minor
          Found in src/index.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 parseMode1 has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const parseMode1 = byte42 => {
            const pModes = {
              '0': 'No navigation solution',
              '1': '1 satellite solution',
              '2': '2 satellite solution',
          Severity: Minor
          Found in src/utils.js - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language