Fantom-foundation/go-evm

View on GitHub

Showing 59 of 59 total issues

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

func transactionReceiptHandler(w http.ResponseWriter, r *http.Request, m *Service) {
    param := r.URL.Path[len("/transaction/"):]
    txHash := common.HexToHash(param)
    m.logger.WithField("tx_hash", txHash.Hex()).Debug("GET tx")

Severity: Major
Found in src/service/http_handlers.go and 1 other location - About 1 day to fix
src/service/http_handlers.go on lines 689..778

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

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

func txReceiptHandler(w http.ResponseWriter, r *http.Request, m *Service) {
    param := r.URL.Path[len("/tx/"):]
    txHash := common.HexToHash(param)
    m.logger.WithField("tx_hash", txHash.Hex()).Debug("GET tx")

Severity: Major
Found in src/service/http_handlers.go and 1 other location - About 1 day to fix
src/service/http_handlers.go on lines 587..676

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

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

    for _, txBytes := range block.Transactions() {
        var t ethTypes.Transaction
        if err := rlp.Decode(bytes.NewReader(txBytes), &t); err != nil {
            m.logger.WithError(err).Error("Decoding Transaction")
            http.Error(w, err.Error(), http.StatusInternalServerError)
Severity: Major
Found in src/service/http_handlers.go and 1 other location - About 1 day to fix
src/service/http_handlers.go on lines 97..177

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

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

    for _, txBytes := range block.Transactions() {
        var t ethTypes.Transaction
        if err := rlp.Decode(bytes.NewReader(txBytes), &t); err != nil {
            m.logger.WithError(err).Error("Decoding Transaction")
            http.Error(w, err.Error(), http.StatusInternalServerError)
Severity: Major
Found in src/service/http_handlers.go and 1 other location - About 1 day to fix
src/service/http_handlers.go on lines 233..313

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

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

    return from.api.sendTx(stx).then( (res) => {
        log(FgGreen, 'Response: ' + res)
        txHash = JSONbig.parse(res).txHash.replace("\"", "")
        return txHash
    })
Severity: Major
Found in demo/nodejs/demo.js and 1 other location - About 1 day to fix
demo/nodejs/demo.js on lines 287..307

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

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

    return from.api.sendTx(stx).then( (res) => {
        log(FgGreen, 'Response: ' + res)
        txHash = JSONbig.parse(res).txHash.replace("\"", "")
        return txHash
    })
Severity: Major
Found in demo/nodejs/demo.js and 1 other location - About 1 day to fix
demo/nodejs/demo.js on lines 226..246

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

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

File web3_account_api.go has 713 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package service

import (
    "bytes"
    "context"
Severity: Minor
Found in src/service/web3_account_api.go - About 7 hrs to fix

    File http_handlers.go has 699 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package service
    
    import (
        "bytes"
        "encoding/json"
    Severity: Minor
    Found in src/service/http_handlers.go - About 6 hrs to fix

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

      EVMLachesisClient.prototype.call = function(tx) {
          var options = {
              host: this.host,
              port: this.port,
              path: '/call',
      Severity: Major
      Found in demo/nodejs/evm-babble-client.js and 2 other locations - About 4 hrs to fix
      demo/nodejs/evm-babble-client.js on lines 77..91
      demo/nodejs/evm-babble-client.js on lines 93..107

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

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

      EVMLachesisClient.prototype.sendRawTx = function(tx) {
          var options = {
              host: this.host,
              port: this.port,
              path: '/rawtx',
      Severity: Major
      Found in demo/nodejs/evm-babble-client.js and 2 other locations - About 4 hrs to fix
      demo/nodejs/evm-babble-client.js on lines 61..75
      demo/nodejs/evm-babble-client.js on lines 77..91

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

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

      EVMLachesisClient.prototype.sendTx = function(tx) {
          var options = {
              host: this.host,
              port: this.port,
              path: '/tx',
      Severity: Major
      Found in demo/nodejs/evm-babble-client.js and 2 other locations - About 4 hrs to fix
      demo/nodejs/evm-babble-client.js on lines 61..75
      demo/nodejs/evm-babble-client.js on lines 93..107

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

      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

      EVMLachesisClient.prototype.getReceipt = function(txHash) {
          var options = {
              host: this.host,
              port: this.port,
              path: '/tx/' + txHash,
      Severity: Major
      Found in demo/nodejs/evm-babble-client.js and 1 other location - About 4 hrs to fix
      demo/nodejs/evm-babble-client.js on lines 31..44

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

      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

      EVMLachesisClient.prototype.getAccount = function(address) {
          var options = {
              host: this.host,
              port: this.port,
              path: '/account/' + address,
      Severity: Major
      Found in demo/nodejs/evm-babble-client.js and 1 other location - About 4 hrs to fix
      demo/nodejs/evm-babble-client.js on lines 109..122

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

      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

      File demo.js has 325 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      util = require('util');
      path = require("path");
      JSONbig = require('json-bigint');
      argv = require('minimist')(process.argv.slice(2));
      prompt = require('prompt');
      Severity: Minor
      Found in demo/nodejs/demo.js - About 3 hrs to fix

        Function blockByIdHandler has 107 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func blockByIdHandler(w http.ResponseWriter, r *http.Request, m *Service) {
            param := r.URL.Path[len("/blockById/"):]
            m.logger.WithField("param", param).Debug("GET account")
            id, err := strconv.ParseInt(param, 10, 64)
            if err != nil {
        Severity: Major
        Found in src/service/http_handlers.go - About 3 hrs to fix

          Function blockByHashHandler has 102 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func blockByHashHandler(w http.ResponseWriter, r *http.Request, m *Service) {
              param := r.URL.Path[len("/block/"):]
              m.logger.WithField("param", param).Debug("GET account")
              hash := common.HexToHash(param)
              m.logger.WithField("hash", hash.Hex()).Debug("GET blockByHashHandler")
          Severity: Major
          Found in src/service/http_handlers.go - About 3 hrs to fix

            RpcServer has 23 methods (exceeds 20 allowed). Consider refactoring.
            Open

            type RpcServer struct {
                backend *Service
            
                eventfeed *event.Feed // Event multiplexer used between the services of a stack
                config    *node.Config
            Severity: Minor
            Found in src/service/rpc_server.go - About 2 hrs to fix

              Function transactionReceiptHandler has 77 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func transactionReceiptHandler(w http.ResponseWriter, r *http.Request, m *Service) {
                  param := r.URL.Path[len("/transaction/"):]
                  txHash := common.HexToHash(param)
                  m.logger.WithField("tx_hash", txHash.Hex()).Debug("GET tx")
              
              
              Severity: Major
              Found in src/service/http_handlers.go - About 2 hrs to fix

                Function txReceiptHandler has 77 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func txReceiptHandler(w http.ResponseWriter, r *http.Request, m *Service) {
                    param := r.URL.Path[len("/tx/"):]
                    txHash := common.HexToHash(param)
                    m.logger.WithField("tx_hash", txHash.Hex()).Debug("GET tx")
                
                
                Severity: Major
                Found in src/service/http_handlers.go - About 2 hrs to fix

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

                  func (n *RpcServer) stopHTTP() {
                      if n.httpListener != nil {
                          err := n.httpListener.Close()
                          n.httpListener = nil
                  
                  
                  Severity: Major
                  Found in src/service/rpc_server.go and 1 other location - About 1 hr to fix
                  src/service/rpc_server.go on lines 299..314

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language