Showing 207 of 208 total issues
Method ExecutionStreamRequest_Filter.Match
has 7 return statements (exceeds 6 allowed). Open
func (f *ExecutionStreamRequest_Filter) Match(e *execution.Execution) bool {
if f == nil {
return true
}
if !f.ExecutorHash.IsZero() && !f.ExecutorHash.Equal(e.ExecutorHash) {
Method ListFilter.Match
has 7 return statements (exceeds 6 allowed). Open
func (f ListFilter) Match(exec *execution.Execution) bool {
if f.Status != execution.Status_Unknown && f.Status != exec.Status {
return false
}
if !f.ProcessHash.IsZero() && !f.ProcessHash.Equal(exec.ProcessHash) {
Method LCD.BroadcastMsgs
has 7 return statements (exceeds 6 allowed). Open
func (lcd *LCD) BroadcastMsgs(msgs []sdk.Msg) ([]byte, error) {
// Lock the getAccount + create and sign tx + broadcast
lcd.broadcastMutex.Lock()
defer lcd.broadcastMutex.Unlock()
Method Authorizer.IsAuthorized
has 7 return statements (exceeds 6 allowed). Open
func (a *Authorizer) IsAuthorized(ctx context.Context, payload interface{}) error {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return fmt.Errorf("signature not found in metadata, make sure to set it using the key %q", RequestSignature)
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (c *RPC) setAccountSequence(seq uint64) error {
c.accountMutex.Lock()
defer c.accountMutex.Unlock()
if c.acc == nil {
return fmt.Errorf("c.acc should not be nil. use GetAccount first")
- Read upRead up
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 102.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (lcd *LCD) setAccountSequence(seq uint64) error {
lcd.accountMutex.Lock()
defer lcd.accountMutex.Unlock()
if lcd.acc == nil {
return fmt.Errorf("lcd.acc should not be nil. use getAccount first")
- Read upRead up
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 102.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method Process_Node_Reference_Path.Resolve
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func (path *Process_Node_Reference_Path) Resolve(data *types.Struct) (*types.Value, error) {
if path == nil {
return &types.Value{Kind: &types.Value_StructValue{StructValue: data}}, 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 startOrchestratorCmd
has a Cognitive Complexity of 21 (exceeds 20 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 {
- 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.Update
has a Cognitive Complexity of 21 (exceeds 20 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)
}
- 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
Your code does not pass gofmt in 1 place. Go fmt your code! Open
// +build tools
- Exclude checks
comment on exported type Keeper should be of the form "Keeper ..." (with optional leading article) Open
// module types
- Exclude checks
comment on exported type GenesisState should be of the form "GenesisState ..." (with optional leading article) Open
// module types
- Exclude checks
comment on exported type GenesisState should be of the form "GenesisState ..." (with optional leading article) Open
// module types
- Exclude checks
a blank import should be only in a main or test package, or have a comment justifying it Open
_ "github.com/go-bindata/go-bindata/go-bindata"
- Exclude checks
comment on exported type Params should be of the form "Params ..." (with optional leading article) Open
// module types
- Exclude checks
comment on exported type Keeper should be of the form "Keeper ..." (with optional leading article) Open
// module types
- Exclude checks
comment on exported type MsgUpdateError should be of the form "MsgUpdateError ..." (with optional leading article) Open
// module types
- Exclude checks
comment on exported type Keeper should be of the form "Keeper ..." (with optional leading article) Open
// module types
- Exclude checks
comment on exported function IsDomainName should be of the form "IsDomainName ..." Open
// Source: https://golang.org/src/net/dnsclient.go
- Exclude checks
comment on exported type Keeper should be of the form "Keeper ..." (with optional leading article) Open
// module types
- Exclude checks