Skip to content

The introduction of golangci-lint during the CI #24

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

Merged
merged 18 commits into from
Aug 30, 2018

Conversation

mattiabertorello
Copy link
Contributor

This PR introduce golangci-lint in the pipeline to improve the code quality through the code static analysis.
I fixed the problems reported by the linters:

  • misspell
  • gofmt
  • unconvert
  • nakedret
  • ineffassign
  • interfacer
  • varcheck
  • lll
  • golint except one problem where I have to modify also vendor dependencies

These linters should be enable after fix the problems

  • deadcode
  • dupl
  • errcheck
  • goconst
  • gocyclo
  • govet
  • maligned
  • megacheck
  • unparam

// or nil if not found.
func (platform *Platform) GetRelease(version *semver.Version) *PlatformRelease {
func (platform *Platform) GetReleaseVersion(version *semver.Version) *PlatformRelease {
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this change, may you explain it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I suppress the warning othewise I have to replace the type *semver.Version with fmt.Stringer
https://github.com/mvdan/interfacer#suppressing-warnings

Copy link
Member

Choose a reason for hiding this comment

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

I see that the method has been renamed from GetRelease to GetReleaseVersion, what's exactly the warning you suppressed with this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the error form the linter interfacer

arduino/cores/cores.go:116:38: `version` can be `fmt.Stringer` (interfacer)
func (platform *Platform) GetRelease(version *semver.Version) *PlatformRelease {

If you want to remove this error you have to use the interface instead the specific struct.
In this way

func (platform *Platform) GetRelease(version fmt.Stringer) *PlatformRelease {
	return platform.Releases[version.String()]
}

Choose the solution that seems better for you, I thought that is necessary use the semver.Version so I prefer to rename the method

Copy link
Member

Choose a reason for hiding this comment

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

Ok, now I understand, changing to fmt.Stringer doesn't look like a great improvement to me.

My problem is that GetReleaseVersion looks like a method to get the Version of a Platform, instead this is a method to find a PlatformRelease with a specific version. Let's call it FindReleaseWithVersion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 9ecd7dd

//var dumpFlags struct {
// _default bool // If false, ask questions to the user about setting configuration properties, otherwise use default configuration.
// location string // The custom location of the file to create.
//}

Copy link
Member

Choose a reason for hiding this comment

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

this can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 833ded1

//const (
// versionAll string = "all"
// versionLatest string = "latest"
//)

Copy link
Member

Choose a reason for hiding this comment

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

remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 833ded1

initCommand.Flags().StringVar(&initFlags.location,
"save-as",
"",
"Sets where to save the configuration file [default is ./.cli-config.yml].")
return initCommand
Copy link
Member

Choose a reason for hiding this comment

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

All these newline changes makes the commands Flags() initialization different with 3 different styles across the codebase:

STYLE 1 (all in one line):

	command.Flags().StringVar(&flags.vidPid, "vid-pid", "", "When specified, VID/PID specific build properties are used, if boards supports them.")

STYLE 2 (break on the description):

	command.Flags().StringVar(&flags.vidPid, "vid-pid", "",
		"When specified, VID/PID specific build properties are used, if boards supports them.")

STYLE 3 (break on all parameters):

	initCommand.Flags().BoolVar(&initFlags._default,
 		"default",
 		false,
 		"If omitted, ask questions to the user about setting configuration properties, otherwise use default configuration.")

IMHO we should change all of them, in the commands/xxxx modules (maybe to STYLE 2 since the line break is likely to happen on the description).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 191cfc3

@cmaglie cmaglie merged commit 35cb251 into master Aug 30, 2018
@cmaglie cmaglie deleted the make-the-linter-happy branch August 30, 2018 11:01
@cmaglie cmaglie added this to the 0.3.1-alpha.preview milestone Oct 25, 2018
per1234 pushed a commit that referenced this pull request Nov 16, 2020
Restructured logging procedures

- updated logging levels per message type (more in the future)
- cleaned up redundancies
- increased performances
- messages only printed during change of state (once)

* - added WiFi Firmware version check and update message
- tested on MKR1000 and MKR1010
NOTE: WiFINina wrongly reports "1.2.0" when WiFi.firmwareVersion() is invoked, although version "1.2.1" is set in the source files
per1234 added a commit that referenced this pull request Aug 9, 2021
Move library.properties schema to dedicated folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants