theQRL/block-explorer

View on GitHub

Showing 51 of 157 total issues

File index.js has 1081 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint no-console: 0, max-len: 0 */
/* global _ */

// server-side startup
import grpc from '@grpc/grpc-js'
Severity: Major
Found in imports/startup/server/index.js - About 2 days to fix

    File address.js has 924 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint no-console: 0 */
    /* ^^^ remove once testing complete
     */
    import JSONFormatter from 'json-formatter-js'
    import qrlAddressValidator from '@theqrl/validate-qrl-address'
    Severity: Major
    Found in imports/ui/components/address/address.js - About 2 days to fix

      `` has 55 functions (exceeds 20 allowed). Consider refactoring.
      Open

      Template.address.helpers({
        bech32() {
          return Session.equals('addressFormat', 'bech32')
        },
        address() {
      Severity: Major
      Found in imports/ui/components/address/address.js - About 7 hrs to fix

        File tx.js has 486 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* eslint no-console: 0 */
        import JSONFormatter from 'json-formatter-js'
        import './tx.html'
        import CryptoJS from 'crypto-js'
        import sha256 from 'sha256'
        Severity: Minor
        Found in imports/ui/components/tx/tx.js - About 7 hrs to fix

          Function addressTransactions has 168 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            addressTransactions(request) {
              check(request, Object)
              console.log(`addressTransactions method called for ${request.tx.length} transactions`)
              const targets = request.tx
              const result = []
          Severity: Major
          Found in imports/startup/server/index.js - About 6 hrs to fix

            `` has 43 functions (exceeds 20 allowed). Consider refactoring.
            Open

            Template.tx.helpers({
              hasMessage() {
                try {
                  if (this.tx.transfer.message_data.length > 0) {
                    return true
            Severity: Minor
            Found in imports/ui/components/tx/tx.js - About 5 hrs to fix

              File cron.js has 355 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /* eslint max-len: 0 */
              /* global _ */
              import { HTTP } from 'meteor/http'
              import { JsonRoutes } from 'meteor/simple:json-routes'
              import { SHA512 } from 'jscrypto/es6'
              Severity: Minor
              Found in imports/startup/server/cron.js - About 4 hrs to fix

                Function block has 108 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  block(blockId) {
                    check(blockId, Number)
                    console.log(`block Method called for: ${blockId}`)
                    if (!(Match.test(blockId, Number)) || (Number.isNaN(blockId))) {
                      const errorCode = 400
                Severity: Major
                Found in imports/startup/server/index.js - About 4 hrs to fix

                  Function helpersaddressTransactions has 105 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const helpersaddressTransactions = (response) => {
                    const output = []
                    // console.log(response)
                    _.each(response.transactions_detail, (tx) => {
                      const txEdited = tx
                  Severity: Major
                  Found in imports/startup/server/index.js - About 4 hrs to fix

                    Function renderAddressBlock has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const renderAddressBlock = () => {
                      const aId = upperCaseFirst(FlowRouter.getParam('aId'))
                      let tPage = FlowRouter.getParam('tPage')
                      tPage = parseInt(tPage, 10)
                      if (!tPage) { tPage = 1 }
                    Severity: Major
                    Found in imports/ui/components/address/address.js - About 3 hrs to fix

                      Function renderChart has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function renderChart() {
                        // Get Chart data from Mongo
                        const chartLineData = homechart.findOne()
                      
                        // Only render chart if we get valid data back
                      Severity: Major
                      Found in imports/ui/pages/home/home.js - About 3 hrs to fix

                        `` has 26 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        Template.lasttx.helpers({
                          lasttx() {
                            const res = lasttx.findOne()
                            return res
                          },
                        Severity: Minor
                        Found in imports/ui/components/lasttx/lasttx.js - About 3 hrs to fix

                          Function getTokenBalances has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const getTokenBalances = (getAddress, callback) => {
                            const request = {
                              address: anyAddressToRaw(getAddress),
                            }
                          
                          
                          Severity: Major
                          Found in imports/ui/components/address/address.js - About 3 hrs to fix

                            Function refreshBlocks has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const refreshBlocks = () => {
                              const request = { filter: 'BLOCKHEADERS', offset: 0, quantity: 10 }
                              const response = Meteor.wrapAsync(getLatestData)(request)
                            
                              // identify miner and calculate total transacted in block
                            Severity: Major
                            Found in imports/startup/server/cron.js - About 2 hrs to fix

                              Function refreshStats has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function refreshStats() {
                                const res = Meteor.wrapAsync(getStats)({ include_timeseries: true })
                              
                                // Save status object
                                status.remove({})
                              Severity: Major
                              Found in imports/startup/server/cron.js - About 2 hrs to fix

                                Function submit #notariseVerificationForm has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  'submit #notariseVerificationForm': (event) => {
                                    event.preventDefault()
                                    event.stopPropagation()
                                
                                    $('#documentVerified').hide()
                                Severity: Major
                                Found in imports/ui/components/tx/tx.js - About 2 hrs to fix

                                  Function getMultiSigAddressState has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  const getMultiSigAddressState = (request, callback) => {
                                    try {
                                      qrlApi('GetMultiSigAddressState', request, (error, response) => {
                                        if (error) {
                                          const myError = errorCallback(error, 'Cannot access API/GetMultiSigAddressState', '**ERROR/getMultiSigAddressState** ')
                                  Severity: Minor
                                  Found in imports/startup/server/index.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 connectToNode has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  const connectToNode = (endpoint, callback) => {
                                    // First check if there is an existing object to store the gRPC connection
                                    if (qrlClient.hasOwnProperty(endpoint) === true) { // eslint-disable-line
                                      console.log('Existing connection found for ', endpoint, ' - attempting getNodeState')
                                      // There is already a gRPC object for this server stored.
                                  Severity: Minor
                                  Found in imports/startup/server/index.js - About 1 hr to fix

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

                                      'submit #notariseVerificationForm': (event) => {
                                        event.preventDefault()
                                        event.stopPropagation()
                                    
                                        $('#documentVerified').hide()
                                    Severity: Minor
                                    Found in imports/ui/components/tx/tx.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 connectToNode has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    const connectToNode = (endpoint, callback) => {
                                      // First check if there is an existing object to store the gRPC connection
                                      if (qrlClient.hasOwnProperty(endpoint) === true) { // eslint-disable-line
                                        console.log('Existing connection found for ', endpoint, ' - attempting getNodeState')
                                        // There is already a gRPC object for this server stored.
                                    Severity: Minor
                                    Found in imports/startup/server/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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language