theQRL/block-explorer

View on GitHub

Showing 158 of 158 total issues

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

      if (tx.tx.token.symbol) {
        txEdited.tx.token.symbol = Buffer.from(txEdited.tx.token.symbol).toString()
      }
Severity: Major
Found in imports/startup/server/index.js and 3 other locations - About 1 hr to fix
imports/startup/server/index.js on lines 363..365
imports/startup/server/index.js on lines 405..409
imports/startup/server/index.js on lines 410..414

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

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 4 locations. Consider refactoring.
Open

      if (tx.tx.transfer_token.name) {
        txEdited.tx.transfer_token.name = Buffer.from(
          txEdited.tx.transfer_token.name,
        ).toString()
      }
Severity: Major
Found in imports/startup/server/index.js and 3 other locations - About 1 hr to fix
imports/startup/server/index.js on lines 360..362
imports/startup/server/index.js on lines 363..365
imports/startup/server/index.js on lines 405..409

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

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

  txhash(txId) {
    check(txId, String)
    console.log(`txhash method called for: ${txId}`)
    // avoid blocking other method calls from same client - *may need to remove for production*
    this.unblock()
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

Function refreshBlocks has a Cognitive Complexity of 12 (exceeds 5 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: Minor
Found in imports/startup/server/cron.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

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

  amount() {
    if (this.tx.transfer) {
      return this.explorer.totalTransferred
    }
    if (this.tx.transfer_token) {
Severity: Major
Found in imports/ui/components/lasttx/lasttx.js and 1 other location - About 1 hr to fix
imports/ui/components/lastunconfirmedtx/lastunconfirmedtx.js on lines 30..38

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

function refreshLasttx() {
  // First get confirmed transactions
  const confirmed = Meteor.wrapAsync(getLatestData)({ filter: 'TRANSACTIONS', offset: 0, quantity: 10 })

  // Now get unconfirmed transactions
Severity: Minor
Found in imports/startup/server/cron.js - About 1 hr to fix

    Function getMultiSigAddressState has 35 lines of code (exceeds 25 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 1 hr to fix

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

        amount() {
          if (this.tx.transfer) {
            return this.explorer.totalTransferred
          }
          if (this.tx.transfer_token) {
      imports/ui/components/lasttx/lasttx.js on lines 17..25

      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

        menuTransactionsActive() {
          if (
            (FlowRouter.getRouteName() === 'Lasttx.home') ||
            (FlowRouter.getRouteName() === 'Tx.home') ||
            (FlowRouter.getRouteName() === 'Address.home')
      Severity: Major
      Found in imports/ui/mobile/mobile.js and 1 other location - About 1 hr to fix
      imports/ui/layouts/body/body.js on lines 136..145

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

      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

        menuTransactionsActive() {
          if (
            FlowRouter.getRouteName() === 'Lasttx.home' ||
            FlowRouter.getRouteName() === 'Tx.home' ||
            FlowRouter.getRouteName() === 'Address.home'
      Severity: Major
      Found in imports/ui/layouts/body/body.js and 1 other location - About 1 hr to fix
      imports/ui/mobile/mobile.js on lines 86..95

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

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

        addressTransactions() {
          try {
            const transactions = []
            const thisAddress = rawAddressToB32Address(
              Session.get('address').state.address
      Severity: Minor
      Found in imports/ui/components/address/address.js - About 1 hr to fix

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

        const addHex = (b) => {
          const result = b
          result.header.hash_header_hex = Buffer.from(result.header.hash_header).toString('hex')
          return result
        }
        Severity: Major
        Found in imports/startup/client/grpc-console-tests.js and 1 other location - About 1 hr to fix
        imports/ui/components/lastblocks/lastblocks.js on lines 7..11

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

        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

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

        const addHex = (b) => {
          const result = b
          result.header.hash_header_hex = Buffer.from(result.header.hash_header).toString('hex')
          return result
        }
        Severity: Major
        Found in imports/ui/components/lastblocks/lastblocks.js and 1 other location - About 1 hr to fix
        imports/startup/client/grpc-console-tests.js on lines 16..20

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

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

        const loadGrpcClient = (endpoint, callback) => {
          // Load qrlbase.proto and fetch current qrl.proto from node
          const options = {
            keepCase: true,
            longs: String,
        Severity: Minor
        Found in imports/startup/server/index.js - About 1 hr to fix

          Function renderTxBlock has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const renderTxBlock = () => {
            const txId = FlowRouter.getParam('txId')
            if (txId) {
              Meteor.call('txhash', txId, (err, res) => {
                if (err) {
          Severity: Minor
          Found in imports/ui/components/tx/tx.js - About 1 hr to fix

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

                        _.each(adjusted.transfer.addrs_to, (thisAddress, index) => {
                          totalOutputs += 1
                          thisTotalTransferred += parseInt(adjusted.transfer.amounts[index], 10)
                          // adjusted.transfer.addrs_to[index] = adjusted.transfer.addrs_to[index] <-- FIXME: why was this here?
                        })
            Severity: Major
            Found in imports/startup/server/index.js and 1 other location - About 1 hr to fix
            imports/startup/server/index.js on lines 857..861

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

            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

                        _.each(adjusted.transfer_token.addrs_to, (thisAddress, index) => {
                          totalOutputs += 1
                          thisTotalTransferred += parseInt(adjusted.transfer_token.amounts[index], 10)
                          // adjusted.transfer_token.addrs_to[index] = adjusted.transfer_token.addrs_to[index] <-- FIXME: why was this here?
                        })
            Severity: Major
            Found in imports/startup/server/index.js and 1 other location - About 1 hr to fix
            imports/startup/server/index.js on lines 837..841

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

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

              'click .themeToggle': () => {
                try {
                  const x = LocalStore.get('theme')
                  if (x === 'dark') {
                    LocalStore.set('theme', 'light')
            Severity: Minor
            Found in imports/ui/layouts/body/body.js - About 1 hr to fix

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

                txhash(txId) {
                  check(txId, String)
                  console.log(`txhash method called for: ${txId}`)
                  // avoid blocking other method calls from same client - *may need to remove for production*
                  this.unblock()
              Severity: Minor
              Found in imports/startup/server/index.js - About 1 hr to fix

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

                  'click .pagination': (event) => {
                    let b = 0
                    Session.set('addressTransactions', {})
                    if (parseInt(event.target.text, 10)) {
                      b = parseInt(event.target.text, 10)
                Severity: Minor
                Found in imports/ui/components/address/address.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