Showing 1,820 of 1,820 total issues
Method LogAttr.Unmarshal
has 111 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *LogAttr) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Allocator.doNetworkAlloc
has 111 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (a *Allocator) doNetworkAlloc(ctx context.Context, ev events.Event) {
nc := a.netCtx
switch v := ev.(type) {
case api.EventCreateNetwork:
Method LogMessage.Unmarshal
has 39 return statements (exceeds 4 allowed). Open
func (m *LogMessage) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Scheduler.Run
has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring. Open
func (s *Scheduler) Run(pctx context.Context) error {
ctx := log.WithModule(pctx, "scheduler")
defer close(s.doneChan)
s.pipeline.AddFilter(&VolumesFilter{vs: s.volumes})
- 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 testSuite.TestNoDuplicateIPs
has 109 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (suite *testSuite) TestNoDuplicateIPs() {
s := store.NewMemoryStore(nil)
suite.NotNil(s)
defer s.Close()
Object
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
type Object struct {
// Types that are valid to be assigned to Object:
// *Object_Node
// *Object_Service
// *Object_Network
StoreAction
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
type StoreAction struct {
Action StoreActionKind `protobuf:"varint,1,opt,name=action,proto3,enum=docker.swarmkit.v1.StoreActionKind" json:"action,omitempty"`
// Types that are valid to be assigned to Target:
// *StoreAction_Node
// *StoreAction_Service
Function ConvertTaskWatch
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
func ConvertTaskWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
var (
m Task
checkFuncs []TaskCheckFunc
hasDesiredState bool
- 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 Assignment.Unmarshal
has 37 return statements (exceeds 4 allowed). Open
func (m *Assignment) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Server.ListTasks
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
func (s *Server) ListTasks(ctx context.Context, request *api.ListTasksRequest) (*api.ListTasksResponse, error) {
var (
tasks []*api.Task
err 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 Dispatcher.Run
has 106 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (d *Dispatcher) Run(ctx context.Context) error {
ctx = log.WithModule(ctx, "dispatcher")
log.G(ctx).Info("dispatcher starting")
d.taskUpdatesLock.Lock()
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (c *Collector) handleTaskEvent(event events.Event) {
var prevTask, newTask *api.Task
switch v := event.(type) {
case api.EventCreateTask:
- 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 264.
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 (c *Collector) handleNodeEvent(event events.Event) {
var prevNode, newNode *api.Node
switch v := event.(type) {
case api.EventCreateNode:
- 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 264.
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 SecretSpec.Unmarshal
has 36 return statements (exceeds 4 allowed). Open
func (m *SecretSpec) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Dispatcher.Tasks
has 104 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (d *Dispatcher) Tasks(r *api.TasksRequest, stream api.Dispatcher_TasksServer) error {
d.rpcRW.RLock()
defer d.rpcRW.RUnlock()
dctx, err := d.isRunningLocked()
Similar blocks of code found in 2 locations. Consider refactoring. Open
func changeNodeAvailability(cmd *cobra.Command, args []string, availability api.NodeSpec_Availability) error {
if len(args) == 0 {
return errors.New("missing node ID")
}
- 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 259.
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 changeNodeRole(cmd *cobra.Command, args []string, role api.NodeRole) error {
if len(args) == 0 {
return errors.New("missing node ID")
}
- 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 259.
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
Function reconcileTaskState
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func reconcileTaskState(ctx context.Context, w *worker, assignments []*api.AssignmentChange, fullSnapshot bool) error {
var (
updatedTasks []*api.Task
removedTasks []*api.Task
)
Function WatchMessageEvent
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func WatchMessageEvent(c Event) *WatchMessage_Event {
switch v := c.(type) {
case EventCreateNode:
return &WatchMessage_Event{Action: WatchActionKindCreate, Object: &Object{Object: &Object_Node{Node: v.Node}}}
case EventUpdateNode:
Method Scheduler.applySchedulingDecisions
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Scheduler) applySchedulingDecisions(ctx context.Context, schedulingDecisions map[string]schedulingDecision) (successful, failed []schedulingDecision) {
// applySchedulingDecisions is the only place where we make store
// transactions in the scheduler. the scheduler is responsible for freeing
// volumes that are no longer in use. this means that volumes should be
// freed in this function. sometimes, there are no scheduling decisions to