Showing 56 of 208 total issues
Function NewInitApp
has 196 lines of code (exceeds 50 allowed). Consider refactoring. Open
func NewInitApp(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
invCheckPeriod uint, skipUpgradeHeights map[int64]bool, baseAppOptions ...func(*bam.BaseApp),
) (*NewApp, error) {
// First define the top level codec that will be shared by the different modules
Method Keeper.Create
has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring. Open
func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreate) (*executionpb.Execution, error) {
run, err := k.runnerKeeper.Get(ctx, msg.ExecutorHash)
if err != nil {
return nil, err
}
- 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 write
has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring. Open
func write(buf *bytes.Buffer, v reflect.Value) *bytes.Buffer {
switch v.Kind() {
case reflect.Bool:
buf.WriteString(strconv.FormatBool(v.Bool()))
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- 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
Method Keeper.Create
has 134 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreate) (*executionpb.Execution, error) {
run, err := k.runnerKeeper.Get(ctx, msg.ExecutorHash)
if err != nil {
return nil, err
}
Method Container.Start
has 124 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *Container) Start(srv *service.Service, instanceHash, runnerHash, instanceEnvHash hash.Hash, instanceEnv []string, registerPayload []byte) (err error) {
// delete the service's container on any error
errorOccurred := true
defer func() {
if errorOccurred {
Function queryListHandlerFn
has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring. Open
func queryListHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
if !ok {
return
- 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
Method Process.Validate
has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring. Open
func (w *Process) Validate() error {
if err := xvalidator.Struct(w); err != nil {
return err
}
if err := w.validate(); 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 write
has 92 lines of code (exceeds 50 allowed). Consider refactoring. Open
func write(buf *bytes.Buffer, v reflect.Value) *bytes.Buffer {
switch v.Kind() {
case reflect.Bool:
buf.WriteString(strconv.FormatBool(v.Bool()))
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
Function AddGenesisAccountCmd
has 92 lines of code (exceeds 50 allowed). Consider refactoring. Open
func AddGenesisAccountCmd(
ctx *server.Context, cdc *codec.Codec, defaultNodeHome, defaultClientHome string,
) *cobra.Command {
cmd := &cobra.Command{
Use: "add-genesis-account [address_or_key_name] [coin][,[coin]]",
Function New
has 90 lines of code (exceeds 50 allowed). Consider refactoring. Open
func New(prefix string) (*validator.Validate, ut.Translator) {
en := en.New()
uni := ut.New(en, en)
trans, _ := uni.GetTranslator("en")
validate := validator.New()
Keybase
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
type Keybase struct {
kb keys.Keybase
mx sync.Mutex
privKeysCache map[[sha256.Size]byte]crypto.PrivKey
}
Function queryListHandlerFn
has 83 lines of code (exceeds 50 allowed). Consider refactoring. Open
func queryListHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
if !ok {
return
Method NewApp.prepForZeroHeightGenesis
has 83 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (app *NewApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []string) {
applyWhiteList := false
//Check if there is a whitelist
if len(jailWhiteList) > 0 {
Function AddGenesisAccountCmd
has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring. Open
func AddGenesisAccountCmd(
ctx *server.Context, cdc *codec.Codec, defaultNodeHome, defaultClientHome string,
) *cobra.Command {
cmd := &cobra.Command{
Use: "add-genesis-account [address_or_key_name] [coin][,[coin]]",
- 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
Method Orchestrator.startExecutionStream
has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring. Open
func (s *Orchestrator) startExecutionStream(ctx context.Context) error {
subscriber := xstrings.RandASCIILetters(8)
query := fmt.Sprintf("%s.%s EXISTS AND %s.%s='%s'",
executionmodule.EventType, executionmodule.AttributeKeyHash,
executionmodule.EventType, sdk.AttributeKeyAction, executionmodule.AttributeActionCompleted,
- 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 New
has 25 return statements (exceeds 6 allowed). Open
func New(prefix string) (*validator.Validate, ut.Translator) {
en := en.New()
uni := ut.New(en, en)
trans, _ := uni.GetTranslator("en")
validate := validator.New()
Function processExec
has 77 lines of code (exceeds 50 allowed). Consider refactoring. Open
func processExec(client runner.RunnerClient, token string, exec *execution.Execution) {
var outputs *types.Struct
if exec.TaskKey == "task_trigger" || exec.TaskKey == "task1" || exec.TaskKey == "task2" {
outputs = &types.Struct{
Fields: map[string]*types.Value{
Method Keeper.Update
has 74 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (k *Keeper) Update(ctx sdk.Context, msg types.MsgUpdate) (*executionpb.Execution, error) {
store := ctx.KVStore(k.storeKey)
if !store.Has(msg.Hash) {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "execution %q doesn't exist", msg.Hash)
}
Method Container.Start
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (c *Container) Start(srv *service.Service, instanceHash, runnerHash, instanceEnvHash hash.Hash, instanceEnv []string, registerPayload []byte) (err error) {
// delete the service's container on any error
errorOccurred := true
defer func() {
if errorOccurred {
- 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 startOrchestratorCmd
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func startOrchestratorCmd(cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "start",
Short: "Start the Orchestrator",
RunE: func(cmd *cobra.Command, args []string) error {