Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update golangci-lint version to v1.21.0 #741

Merged
merged 1 commit into from
Dec 12, 2019
Merged

Update golangci-lint version to v1.21.0 #741

merged 1 commit into from
Dec 12, 2019

Conversation

woohhan
Copy link

@woohhan woohhan commented Dec 12, 2019

Signed-off-by: Woohyung Han techhanx@gmail.com

Describe what this PR does

Update golangci-lint version to v1.21.0

Is there anything that requires special attention

Most of issue was unnecessary trailing newline, unnecessary leading newline.

// BAD
		return err

	}
	return nil
}

// GOOD
		return err
	}
	return nil
}

I disabled following linters

  1. godox: Tool for detection of FIXME, TODO and other comment keywords
  2. wsl: Whitespace Linter, has assignments should only be cuddled with other assignments rule. This rule force to cuddle all assignements. (need new line after assignements). I think It's not so cool, see following example. and we have simllary linter for detecting trailing. the whitespace linter to detect leading and trailing whitespace.
// BAD (by wsl)
	_, err := framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisioner)
	if err != nil {
		e2elog.Logf("failed to delete cephfs provisioner %v", err)
	}
	_, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisionerRBAC)
	if err != nil {
		e2elog.Logf("failed to delete cephfs provisioner rbac %v", err)
	}

// GOOD
	_, err := framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisioner)
	
	if err != nil {
		e2elog.Logf("failed to delete cephfs provisioner %v", err)
	}
	
	_, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisionerRBAC)
	
	if err != nil {
		e2elog.Logf("failed to delete cephfs provisioner rbac %v", err)
	}
  1. funlen: Tool for detection of long functions. I don't think this is needed for golang. golang has no column limit.

Related issues

Fixes: #736

Future concerns

We have one warning in the test, and this is golangci-lint issue. golangci/golangci-lint#827

WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: 
(...)

I'm not sure about these. Please take a look these.

  • We have the gocognit lint for Computes and checks the cognitive complexity of functions. But the min-complexity value with default (30) is not passed the test for now. I think we can just disable this lint, or need to refactor to pass the lint. (maybe another pull request?)
  • I found yamllint not working correctly in my desktop with following error. Perhaps we need to check this too.
yamllint -s -d {extends: default, rules: {line-length: {allow-non-breakable-inline-mappings: true}},ignore: charts/*/templates/*.yaml} ./.mergify.yml 
[DEPRECATION] The trollop gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
Error: unknown argument '-s'.
Try --help for help.

Signed-off-by: Woohyung Han <techhanx@gmail.com>
@Madhu-1
Copy link
Collaborator

Madhu-1 commented Dec 12, 2019

Signed-off-by: Woohyung Han techhanx@gmail.com

Describe what this PR does

Update golangci-lint version to v1.21.0

Is there anything that requires special attention

Most of issue was unnecessary trailing newline, unnecessary leading newline.

// BAD
		return err

	}
	return nil
}

// GOOD
		return err
	}
	return nil
}

I disabled following linters

  1. godox: Tool for detection of FIXME, TODO and other comment keywords
  2. wsl: Whitespace Linter, has assignments should only be cuddled with other assignments rule. This rule force to cuddle all assignements. (need new line after assignements). I think It's not so cool, see following example. and we have simllary linter for detecting trailing. the whitespace linter to detect leading and trailing whitespace.
// BAD (by wsl)
	_, err := framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisioner)
	if err != nil {
		e2elog.Logf("failed to delete cephfs provisioner %v", err)
	}
	_, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisionerRBAC)
	if err != nil {
		e2elog.Logf("failed to delete cephfs provisioner rbac %v", err)
	}

// GOOD
	_, err := framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisioner)
	
	if err != nil {
		e2elog.Logf("failed to delete cephfs provisioner %v", err)
	}
	
	_, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisionerRBAC)
	
	if err != nil {
		e2elog.Logf("failed to delete cephfs provisioner rbac %v", err)
	}
  1. funlen: Tool for detection of long functions. I don't think this is needed for golang. golang has no column limit.

i think we should limit to some value (around 120), having long function is diffficult to read, can we track this in seperate issue?

Related issues

Fixes: #736

Future concerns

We have one warning in the test, and this is golangci-lint issue. golangci/golangci-lint#827

WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: 
(...)

as this is a golangci-lint issue once this is fixed will update to newer version


I'm not sure about these. Please take a look these.

* We have the [gocognit](https://github.com/uudashr/gocognit) lint for `Computes and checks the cognitive complexity of functions`. But the min-complexity value with default (30) is not passed the test for now. I think we can just disable this lint, or need to refactor to pass the lint. (maybe another pull request?)

as you added this as TODO this can be enabled later also.

  • I found yamllint not working correctly in my desktop with following error. Perhaps we need to check this too.
yamllint -s -d {extends: default, rules: {line-length: {allow-non-breakable-inline-mappings: true}},ignore: charts/*/templates/*.yaml} ./.mergify.yml 
[DEPRECATION] The trollop gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
Error: unknown argument '-s'.
Try --help for help.

Check yamllint version in your local system.

Copy link
Collaborator

@Madhu-1 Madhu-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks @WoohyungHan

@humblec
Copy link
Collaborator

humblec commented Dec 12, 2019

LGTM.. Thanks !

@humblec humblec added the release-2.0.0 v2.0.0 release label Dec 12, 2019
@mergify mergify bot merged commit 8a16f74 into ceph:master Dec 12, 2019
@woohhan woohhan deleted the update_golangci-lint_1.21.0 branch December 12, 2019 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-2.0.0 v2.0.0 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update golangci-lint to latest released version 1.21.0
3 participants