Showing 1,008 of 1,820 total issues
Resource
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Resource struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Meta Meta `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta"`
Annotations Annotations `protobuf:"bytes,3,opt,name=annotations,proto3" json:"annotations"`
// Kind identifies this class of object. It is essentially a namespace
Task
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Task struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Meta Meta `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta"`
// Spec defines the desired state of the task as specified by the user.
// The system will honor this and will *never* modify it.
Service
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Service struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Meta Meta `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta"`
Spec ServiceSpec `protobuf:"bytes,3,opt,name=spec,proto3" json:"spec"`
// SpecVersion versions Spec, to identify changes in the spec. Note that
Config
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Config struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Meta Meta `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta"`
// Spec contains the actual config data, as well as any context around the
// config data that the user provides.
Node
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Node struct {
// ID specifies the identity of the node.
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Meta Meta `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta"`
// Spec defines the desired state of the node as specified by the user.
Extension
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Extension struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Meta Meta `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta"`
Annotations Annotations `protobuf:"bytes,3,opt,name=annotations,proto3" json:"annotations"`
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`
Secret
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Secret struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Meta Meta `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta"`
// Spec contains the actual secret data, as well as any context around the
// secret data that the user provides.
Cluster
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Cluster struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Meta Meta `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta"`
Spec ClusterSpec `protobuf:"bytes,3,opt,name=spec,proto3" json:"spec"`
// RootCA contains key material for the root CA.
Network
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Network struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Meta Meta `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta"`
Spec NetworkSpec `protobuf:"bytes,3,opt,name=spec,proto3" json:"spec"`
// Driver specific operational state provided by the network driver.
Volume
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Volume struct {
// ID is the swarmkit-internal ID for this volume object. This has no
// relation to the CSI volume identifier provided by the CSI Plugin.
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Meta Meta `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta"`
Function parseResource
has 87 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func parseResource(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
if flags.Changed("memory-reservation") {
if spec.Task.Resources == nil {
spec.Task.Resources = &api.ResourceRequirements{}
}
Function printNodeSummary
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func printNodeSummary(node *api.Node) {
w := tabwriter.NewWriter(os.Stdout, 8, 8, 8, ' ', 0)
defer func() {
// Ignore flushing errors - there's nothing we can do.
_ = w.Flush()
Function NodeMatches
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func NodeMatches(constraints []Constraint, n *api.Node) bool {
for _, constraint := range constraints {
switch {
case strings.EqualFold(constraint.key, "node.id"):
if !constraint.Match(n.ID) {
Function printNetworkSummary
has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring. Open
Open
func printNetworkSummary(network *api.Network) {
w := tabwriter.NewWriter(os.Stdout, 8, 8, 8, ' ', 0)
defer func() {
// Ignore flushing errors - there's nothing we can do.
_ = w.Flush()
- 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 worker.Subscribe
has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring. Open
Open
func (w *worker) Subscribe(ctx context.Context, subscription *api.SubscriptionMessage) error {
log.G(ctx).Debugf("Received subscription %s (selector: %v)", subscription.ID, subscription.Selector)
publisher, cancel, err := w.publisherProvider.Publisher(ctx, subscription.ID)
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
Method IssueNodeCertificateRequest.Unmarshal
has 27 return statements (exceeds 4 allowed). Open
Open
func (m *IssueNodeCertificateRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method LogContext.Unmarshal
has 27 return statements (exceeds 4 allowed). Open
Open
func (m *LogContext) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method LogSelector.Unmarshal
has 27 return statements (exceeds 4 allowed). Open
Open
func (m *LogSelector) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method SelectByCustom.Unmarshal
has 27 return statements (exceeds 4 allowed). Open
Open
func (m *SelectByCustom) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method ContainerSpec_DNSConfig.Unmarshal
has 27 return statements (exceeds 4 allowed). Open
Open
func (m *ContainerSpec_DNSConfig) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx