theQRL/block-explorer

View on GitHub
imports/ui/components/address/address.js

Summary

Maintainability
F
6 days
Test Coverage

File address.js has 931 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

      Function renderAddressBlock has 80 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 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 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

            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

            Function click .pagination has 27 lines of code (exceeds 25 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

              Function loadAddressTransactions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function loadAddressTransactions(aId, page) {
                Session.set('addressTransactions', [])
                $('#loadingTransactions').show()
                // console.log('Getting transactions for page ', page)
                const addresstx = anyAddressToRaw(aId)
              Severity: Minor
              Found in imports/ui/components/address/address.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                            if (!(res.state.address)) {
                              res.state.address = aId
                            }
                Severity: Major
                Found in imports/ui/components/address/address.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if (parseInt(res.state.txcount, 10) === 0 && parseInt(res.state.nonce, 10) === 0) {
                                res.state.empty_warning = true
                              } else {
                                res.state.empty_warning = false
                              }
                  Severity: Major
                  Found in imports/ui/components/address/address.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                    if (symbol.slice(0, 8) === '00ff00ff') {
                                      const nftBytes = Buffer.concat([
                                        Buffer.from(tokenDetails.symbol),
                                        Buffer.from(tokenDetails.name),
                                      ])
                    Severity: Major
                    Found in imports/ui/components/address/address.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                    while (pages.length !== numPages) {
                                      pages.push({
                                        number: pages.length + 1,
                                        from: ((pages.length + 1) * 10) + 1,
                                        to: ((pages.length + 1) * 10) + 10,
                      Severity: Major
                      Found in imports/ui/components/address/address.js - About 45 mins to fix

                        Function pages has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          pages() {
                            let ret = []
                            const active = Session.get('active')
                            if (Session.get('pages').length > 0) {
                              ret = Session.get('pages')
                        Severity: Minor
                        Found in imports/ui/components/address/address.js - About 45 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

                        Function renderAddressBlock has a Cognitive Complexity of 7 (exceeds 5 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: Minor
                        Found in imports/ui/components/address/address.js - About 35 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

                        Function color has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                          color() {
                            let ret = ''
                            if (this.found) {
                              if (this.transaction.tx.transactionType === 'coinbase') {
                                ret = 'teal'
                        Severity: Minor
                        Found in imports/ui/components/address/address.js - About 35 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

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

                          providerURL() {
                            let id
                            if (this.token) {
                              id = this.token.nft.id
                            } else {
                        Severity: Major
                        Found in imports/ui/components/address/address.js and 1 other location - About 4 hrs to fix
                        imports/ui/components/address/address.js on lines 446..460

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

                        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

                          providerName() {
                            let id
                            if (this.token) {
                              id = this.token.nft.id
                            } else {
                        Severity: Major
                        Found in imports/ui/components/address/address.js and 1 other location - About 4 hrs to fix
                        imports/ui/components/address/address.js on lines 431..445

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

                        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

                          isCreateNFT() {
                            try {
                              if (this.token.nft.type === 'CREATE NFT') {
                                return true
                              }
                        Severity: Minor
                        Found in imports/ui/components/address/address.js and 1 other location - About 55 mins to fix
                        imports/ui/components/address/address.js on lines 381..390

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

                        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

                          Meteor.call('QRLvalue', (err, res) => {
                            if (err) {
                              Session.set('qrl', 'Error getting value from API')
                            } else {
                              Session.set('qrl', res)
                        Severity: Minor
                        Found in imports/ui/components/address/address.js and 1 other location - About 55 mins to fix
                        imports/ui/components/tx/tx.js on lines 29..35

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

                        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

                          isNFTTransfer() {
                            try {
                              if (this.transfer_token.nft.type === 'TRANSFER NFT') {
                                return true
                              }
                        Severity: Minor
                        Found in imports/ui/components/address/address.js and 1 other location - About 55 mins to fix
                        imports/ui/components/address/address.js on lines 365..374

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

                        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

                        There are no issues that match your filters.

                        Category
                        Status