Showing 38 of 59 total issues
File web3_account_api.go
has 713 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package service
import (
"bytes"
"context"
File http_handlers.go
has 699 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package service
import (
"bytes"
"encoding/json"
File demo.js
has 325 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
util = require('util');
path = require("path");
JSONbig = require('json-bigint');
argv = require('minimist')(process.argv.slice(2));
prompt = require('prompt');
Function blockByIdHandler
has 107 lines of code (exceeds 50 allowed). Consider refactoring. Open
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 {
Function blockByHashHandler
has 102 lines of code (exceeds 50 allowed). Consider refactoring. Open
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")
RpcServer
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type RpcServer struct {
backend *Service
eventfeed *event.Feed // Event multiplexer used between the services of a stack
config *node.Config
Function transactionReceiptHandler
has 77 lines of code (exceeds 50 allowed). Consider refactoring. Open
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")
Function txReceiptHandler
has 77 lines of code (exceeds 50 allowed). Consider refactoring. Open
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")
Function NewInmemEngine
has 63 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func NewInmemEngine(config config.Config, logger *logrus.Logger) (*InmemEngine, error) {
submitCh := make(chan []byte)
state, err := state.NewState(logger,
config.Eth.DbFile,
Method State.applyTransaction
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *State) applyTransaction(txBytes []byte, txIndex int, blockHash common.Hash) error {
var t ethTypes.Transaction
if err := rlp.Decode(bytes.NewReader(txBytes), &t); err != nil {
s.logger.WithError(err).Error("Decoding Transaction")
Function parseLogs
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Contract.prototype.parseLogs = function(logs) {
let c = this
// pattern similar to lib/web3/contract.js: addEventsToContract()
let decoders = c.w3.abi.filter(function (json) {
return json.type === 'event';
Function blockByIdHandler
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
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 {
- Read upRead up
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 blockByHashHandler
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
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")
- Read upRead up
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 blockByIdHandler
has 9 return statements (exceeds 4 allowed). Open
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 {
Function NewWriteAheadState
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewWriteAheadState(db ethdb.Database,
root common.Hash,
signer ethTypes.Signer,
chainConfig params.ChainConfig,
vmConfig vm.Config,
Function blockByHashHandler
has 8 return statements (exceeds 4 allowed). Open
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")
Function NewInmemEngine
has 8 return statements (exceeds 4 allowed). Open
Open
func NewInmemEngine(config config.Config, logger *logrus.Logger) (*InmemEngine, error) {
submitCh := make(chan []byte)
state, err := state.NewState(logger,
config.Eth.DbFile,
Method RpcServer.startHTTP
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (n *RpcServer) startHTTP(endpoint string, apis []rpc.API, modules []string, cors []string, vhosts []string, timeouts rpc.HTTPTimeouts) error {
Method PublicTransactionPoolAPI.SignTransaction
has 7 return statements (exceeds 4 allowed). Open
Open
func (s *PublicTransactionPoolAPI) SignTransaction(ctx context.Context, args SendTxArgs) (*SignTransactionResult, error) {
if args.Gas == nil {
return nil, fmt.Errorf("gas not specified")
}
Method WriteAheadState.Commit
has 7 return statements (exceeds 4 allowed). Open
Open
func (was *WriteAheadState) Commit() (common.Hash, error) {
//commit all state changes to the database
root, err := was.ethState.Commit(true)
if err != nil {
was.logger.WithError(err).Error("Committing state")