Showing 15 of 15 total issues
Method ServiceFWD.SyncPodForwards
has a Cognitive Complexity of 52 (exceeds 20 allowed). Consider refactoring. Open
func (svcFwd *ServiceFWD) SyncPodForwards(force bool) {
sync := func() {
defer func() { svcFwd.LastSyncedAt = time.Now() }()
- 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 runCmd
has 130 lines of code (exceeds 50 allowed). Consider refactoring. Open
func runCmd(cmd *cobra.Command, _ []string) {
if verbose {
log.SetLevel(log.DebugLevel)
}
Method ServiceFWD.LoopPodsToForward
has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring. Open
func (svcFwd *ServiceFWD) LoopPodsToForward(pods []v1.Pod, includePodNameInHost bool) {
publisher := &fwdpub.Publisher{
PublisherName: "Services",
Output: false,
}
- 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 ServiceFWD.LoopPodsToForward
has 110 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (svcFwd *ServiceFWD) LoopPodsToForward(pods []v1.Pod, includePodNameInHost bool) {
publisher := &fwdpub.Publisher{
PublisherName: "Services",
Output: false,
}
Function runCmd
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
func runCmd(cmd *cobra.Command, _ []string) {
if verbose {
log.SetLevel(log.DebugLevel)
}
- 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 ForwardIPOpts.MatchList
has 77 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (o ForwardIPOpts) MatchList() []string {
if o.ClusterN == 0 && o.NamespaceN == 0 {
return []string{
o.PodName,
Method PortForwardOpts.AddHosts
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (pfo *PortForwardOpts) AddHosts() {
pfo.HostFile.Lock()
// pfo.Service holds only the service name
Method PortForwardOpts.PortForward
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (pfo *PortForwardOpts) PortForward() error {
defer close(pfo.DoneChan)
transport, upgrader, err := spdy.RoundTripperFor(&pfo.Config)
if err != nil {
Method ServiceFWD.SyncPodForwards
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (svcFwd *ServiceFWD) SyncPodForwards(force bool) {
sync := func() {
defer func() { svcFwd.LastSyncedAt = time.Now() }()
Function ReadyInterface
has 7 return statements (exceeds 4 allowed). Open
func ReadyInterface(opts fwdIp.ForwardIPOpts) (net.IP, error) {
ip, _ := fwdIp.GetIp(opts)
// lo means we are probably on linux and not mac
Method PortForwardOpts.PortForward
has 6 return statements (exceeds 4 allowed). Open
func (pfo *PortForwardOpts) PortForward() error {
defer close(pfo.DoneChan)
transport, upgrader, err := spdy.RoundTripperFor(&pfo.Config)
if err != nil {
Function getForwardConfiguration
has 5 return statements (exceeds 4 allowed). Open
func getForwardConfiguration(opts ForwardIPOpts) *ForwardConfiguration {
if forwardConfiguration != nil {
return forwardConfiguration
}
Function BackupHostFile
has 5 return statements (exceeds 4 allowed). Open
func BackupHostFile(hostFile *txeh.Hosts) (string, error) {
homeDirLocation, err := os.UserHomeDir()
if err != nil {
return "", err
}
Method PortForwardOpts.WaitUntilPodRunning
has 5 return statements (exceeds 4 allowed). Open
func (pfo *PortForwardOpts) WaitUntilPodRunning(stopChannel <-chan struct{}) (*v1.Pod, error) {
pod, err := pfo.ClientSet.CoreV1().Pods(pfo.Namespace).Get(context.TODO(), pfo.PodName, metav1.GetOptions{})
if err != nil {
return nil, err
}
Function ipFromString
has 5 return statements (exceeds 4 allowed). Open
func ipFromString(ipStr string) (net.IP, error) {
ipParts := strings.Split(ipStr, ".")
octet0, err := strconv.Atoi(ipParts[0])
if err != nil {