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

Enable more golang-ci linters #1149

Merged
merged 7 commits into from
Jul 18, 2022

Conversation

timvaillancourt
Copy link
Collaborator

@timvaillancourt timvaillancourt commented Jul 12, 2022

Description

This PR enables a number of linters in the golang-ci Actions job:

  • contextcheck - check the function whether use a non-inherited context
  • durationcheck - check for two durations multiplied together
  • errname - Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
  • execinquery - execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds
  • gofmt - Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
  • ifshort - Checks that your code uses short syntax for if-statements whenever possible
  • misspell - Finds commonly misspelled English words in comments
  • nilerr - Finds the code that returns nil even if it checks that the error is not nil
  • nolintlint - Reports ill-formed or insufficient nolint directives
  • nosprintfhostport - Checks for misuse of Sprintf to construct a host with port in a URL
  • prealloc - Finds slice declarations that could potentially be pre-allocated
  • unconvert - Remove unnecessary type conversions
  • wastedassign - wastedassign finds wasted assignment statements
  • whitespace - Tool for detection of leading and trailing whitespace

This PR also contains fixes for linter warnings this introduced, mostly for ifshort, unconvert and wastedassign

In case this PR introduced Go code changes:

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

@timvaillancourt timvaillancourt added this to the v1.1.6 milestone Jul 12, 2022
@timvaillancourt timvaillancourt changed the title More golang ci linters Enable more golang-ci linters Jul 12, 2022
@timvaillancourt timvaillancourt merged commit ffe54f4 into github:master Jul 18, 2022
@timvaillancourt timvaillancourt deleted the more-golang-ci-linters branch July 18, 2022 16:37
@RainbowDashy
Copy link

I wonder why these lines are not spotted by nilerr.

if err := this.finalCleanup(); err != nil {
	return nil
}

https://github.com/timvaillancourt/gh-ost/blob/baa85a5fe14fd20dc3cc7cf03f880f3800365acb/go/logic/migrator.go#L443-L445

RainbowDashy pushed a commit to bytebase/gh-ost that referenced this pull request Dec 13, 2022
d-bytebase pushed a commit to bytebase/gh-ost that referenced this pull request Dec 13, 2022
* Add script and docs for linter (github#1151)

* Enable more `golang-ci` linters (github#1149)

* Only build RPM and deb packages for amd64

* Convert character to bytes and insert into table using latin1

* delete junk files

* restore connection charset to utf8mb4

* Allow zero in dates (github#1161)

* Merge pull request #31 from openark/zero-date

Support zero date and zero in date, via dedicated command line flag

* Merge pull request #32 from openark/existing-date-with-zero

Support tables with existing zero dates

* Remove un-needed ignore_versions file

* Fix new lint errors from golang-ci update

Co-authored-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* Add missing doc from PR github#1131 (github#1162)

* Set a transaction isolation level for MySQL connections (github#1156)

* Set transaction isolation in connections

* Revert load_map.go change

* Var rename

* Restore comment

* Some fix to unit tests.

* convert to bytes if character string without charsetConversion.

* chore: remove duplicate word in comments (github#1175)

Signed-off-by: Abirdcfly <fp544037857@gmail.com>

Signed-off-by: Abirdcfly <fp544037857@gmail.com>

* Improve applier `.ReadMigrationRangeValues()` func accuracy (github#1164)

* Use a transaction in applier `ReadMigrationRangeValues` func

* Private func names

* Add basic tests for applier (github#1165)

* Add basic tests for applier

* Add header

* Add basic test for inspector (github#1166)

* Add basic test for inspector

* Add header

* Fix return

* Add basic tests to migrator (github#1168)

* add-rocksdb-as-transactional-engine

* Add basic test for hooks (github#1179)

* Enable more `golangci-lint` linters (github#1181)

* Print status to migration context logger

* fix CI tests to ubuntu-20.04 because ubuntu-22.04 (current -latest) doesn't support MySQL 5.7

* temp commit to investigate datetime-with-zero test failure

* more testing

* add extra debugging output

* debugging

* add error detection for test setup, sort tests to make it easier to track progress

* fix broken test by removing invalid insert statement

* Fix: Change table name

table name is 'tbl' not 'tble'

* Attempt instant DDL if supported

* minor cleanup

* Add tests, incorporate feedback

* Improve docs

* Address PR feedback

* Make it clear in docs it is disabled by default but safe.

* Update go/logic/migrator.go

Co-authored-by: dm-2 <45519614+dm-2@users.noreply.github.com>

* remove useless func per review

* support rocksdb as transactional engine

* Modify tests to support rocksdb tests

* SetConnectionConfig

* add support for rocksdb

* add support for rocksdb

* add percona to versions in workflows

* add description and optimize tests

* Apply suggestions from code review

Co-authored-by: dm-2 <45519614+dm-2@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Tim Vaillancourt <tim@timvaillancourt.com>

* Update go/logic/applier.go

Signed-off-by: Abirdcfly <fp544037857@gmail.com>
Co-authored-by: Tim Vaillancourt <tim@timvaillancourt.com>
Co-authored-by: dm-2 <45519614+dm-2@users.noreply.github.com>
Co-authored-by: wangzihuacool <wangzihuacool@163.com>
Co-authored-by: wangzihuacool <47876169+wangzihuacool@users.noreply.github.com>
Co-authored-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Co-authored-by: Abirdcfly <fp544037857@gmail.com>
Co-authored-by: Nicholas Calugar <nicholas.calugar@gusto.com>
Co-authored-by: Hasan Mshawrab <63023909+hasanMshawrab@users.noreply.github.com>
Co-authored-by: Morgan Tocker <mtocker@squareup.com>
Co-authored-by: Morgan Tocker <tocker@gmail.com>
Co-authored-by: lukelewang <lukelewang@tencent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants