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

Fix/naming conventions #156

Merged
merged 3 commits into from
Jul 17, 2020

Conversation

vlastahajek
Copy link
Contributor

Closes #147.

  • Introducing new *API interfaces with the proper name of types, methods, and arguments.

  • Original API kept, but it have been deprecated. It will be removed in the next release

  • Files with completely deprecated API were put to *_deprecated.go files.

  • Some tests have been duplicated to test both new and original API. Tests testing deprecated API are placed in *deprecated_test.go files.

  • CHANGELOG.md updated

  • Rebased/mergeable

  • Tests pass

@vlastahajek vlastahajek requested a review from sranka July 16, 2020 17:23
Copy link
Contributor

@sranka sranka left a comment

Choose a reason for hiding this comment

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

How do we ensure that the required naming conventions are verified during CI? Assuming that the naming violations were originally reported by staticcheck, it seems to me that this PR only changes the circle CI staticcheck execution to additionally remove SA1019.

@vlastahajek
Copy link
Contributor Author

Bellow is run from: staticcheck --checks="all" ./.... A had to disable SA1019, cause it is part of the default checks set and makes check failing. Most of the issues are in the *deprecated sources, few of them remains on deprecated methods in the Client interface and the Options type

api\authorizations_deprecated.go:14:6: type AuthorizationsApi should be AuthorizationsAPI (ST1003)
api\authorizations_deprecated.go:20:50: interface method parameter userId should be userID (ST1003)
api\authorizations_deprecated.go:24:49: interface method parameter orgId should be orgID (ST1003)
api\authorizations_deprecated.go:28:52: interface method parameter orgId should be orgID (ST1003)
api\authorizations_deprecated.go:30:49: interface method parameter authId should be authID (ST1003)
api\authorizations_deprecated.go:32:43: interface method parameter authId should be authID (ST1003)
api\authorizations_deprecated.go:35:6: type authorizationsApiImpl should be authorizationsAPIImpl (ST1003)
api\authorizations_deprecated.go:39:1: comment on exported function NewAuthorizationsApi should be of the form "NewAuthorizationsApi ..." (ST1020)
api\authorizations_deprecated.go:40:6: func NewAuthorizationsApi should be NewAuthorizationsAPI (ST1003)
api\authorizations_deprecated.go:54:33: method FindAuthorizationsByUserId should be FindAuthorizationsByUserID (ST1003)
api\authorizations_deprecated.go:54:81: method parameter userId should be userID (ST1003)
api\authorizations_deprecated.go:62:33: method FindAuthorizationsByOrgId should be FindAuthorizationsByOrgID (ST1003)
api\authorizations_deprecated.go:62:80: method parameter orgId should be orgID (ST1003)
api\authorizations_deprecated.go:70:33: method CreateAuthorizationWithOrgId should be CreateAuthorizationWithOrgID (ST1003)
api\authorizations_deprecated.go:70:83: method parameter orgId should be orgID (ST1003)
api\authorizations_deprecated.go:74:80: method parameter authId should be authID (ST1003)
api\authorizations_deprecated.go:78:74: method parameter authId should be authID (ST1003)
api\buckets_deprecated.go:14:6: type BucketsApi should be BucketsAPI (ST1003)
api\buckets_deprecated.go:20:38: interface method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:22:42: interface method parameter orgId should be orgID (ST1003)
api\buckets_deprecated.go:30:50: interface method parameter orgId should be orgID (ST1003)
api\buckets_deprecated.go:36:42: interface method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:40:40: interface method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:44:39: interface method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:44:49: interface method parameter memberId should be memberID (ST1003)
api\buckets_deprecated.go:48:42: interface method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:48:52: interface method parameter memberId should be memberID (ST1003)
api\buckets_deprecated.go:52:39: interface method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:56:38: interface method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:56:48: interface method parameter memberId should be memberID (ST1003)
api\buckets_deprecated.go:60:41: interface method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:60:51: interface method parameter memberId should be memberID (ST1003)
api\buckets_deprecated.go:63:6: type bucketsApiImpl should be bucketsAPIImpl (ST1003)
api\buckets_deprecated.go:67:1: comment on exported function NewBucketsApi should be of the form "NewBucketsApi ..." (ST1020)
api\buckets_deprecated.go:68:6: func NewBucketsApi should be NewBucketsAPI (ST1003)
api\buckets_deprecated.go:82:26: method FindBucketById should be FindBucketByID (ST1003)
api\buckets_deprecated.go:82:62: method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:86:26: method FindBucketsByOrgId should be FindBucketsByOrgID (ST1003)
api\buckets_deprecated.go:86:66: method parameter orgId should be orgID (ST1003)
api\buckets_deprecated.go:98:26: method CreateBucketWithNameWithId should be CreateBucketWithNameWithID (ST1003)
api\buckets_deprecated.go:98:74: method parameter orgId should be orgID (ST1003)
api\buckets_deprecated.go:109:26: method DeleteBucketWithId should be DeleteBucketWithID (ST1003)
api\buckets_deprecated.go:109:66: method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:121:26: method GetMembersWithId should be GetMembersWithID (ST1003)
api\buckets_deprecated.go:121:64: method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:129:26: method AddMemberWithId should be AddMemberWithID (ST1003)
api\buckets_deprecated.go:129:63: method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:129:73: method parameter memberId should be memberID (ST1003)
api\buckets_deprecated.go:137:26: method RemoveMemberWithId should be RemoveMemberWithID (ST1003)
api\buckets_deprecated.go:137:66: method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:137:76: method parameter memberId should be memberID (ST1003)
api\buckets_deprecated.go:145:26: method GetOwnersWithId should be GetOwnersWithID (ST1003)
api\buckets_deprecated.go:145:63: method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:153:26: method AddOwnerWithId should be AddOwnerWithID (ST1003)
api\buckets_deprecated.go:153:62: method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:153:72: method parameter ownerId should be ownerID (ST1003)
api\buckets_deprecated.go:161:26: method RemoveOwnerWithId should be RemoveOwnerWithID (ST1003)
api\buckets_deprecated.go:161:65: method parameter bucketId should be bucketID (ST1003)
api\buckets_deprecated.go:161:75: method parameter memberId should be memberID (ST1003)
api\delete_deprecated.go:18:6: type DeleteApi should be DeleteAPI (ST1003)
api\delete_deprecated.go:22:36: interface method parameter orgId should be orgID (ST1003)
api\delete_deprecated.go:22:43: interface method parameter bucketId should be bucketID (ST1003)
api\delete_deprecated.go:27:6: type deleteApiImpl should be deleteAPIImpl (ST1003)
api\delete_deprecated.go:31:1: comment on exported function NewDeleteApi should be of the form "NewDeleteApi ..." (ST1020)
api\delete_deprecated.go:32:6: func NewDeleteApi should be NewDeleteAPI (ST1003)
api\delete_deprecated.go:42:25: method DeleteWithId should be DeleteWithID (ST1003)
api\delete_deprecated.go:42:59: method parameter orgId should be orgID (ST1003)
api\delete_deprecated.go:42:66: method parameter bucketId should be bucketID (ST1003)
api\http\options.go:27:19: method TlsConfig should be TLSConfig (ST1003)
api\http\options.go:39:19: method SetTlsConfig should be SetTLSConfig (ST1003)
api\http\options.go:50:19: method HttpRequestTimeout should be HTTPRequestTimeout (ST1003)
api\http\options.go:62:19: method SetHttpRequestTimeout should be SetHTTPRequestTimeout (ST1003)
api\labels_deprecated.go:14:6: type LabelsApi should be LabelsAPI (ST1003)
api\labels_deprecated.go:24:39: interface method parameter orgId should be orgID (ST1003)
api\labels_deprecated.go:32:49: interface method parameter orgId should be orgID (ST1003)
api\labels_deprecated.go:42:6: type labelsApiImpl should be labelsAPIImpl (ST1003)
api\labels_deprecated.go:46:1: comment on exported function NewLabelsApi should be of the form "NewLabelsApi ..." (ST1020)
api\labels_deprecated.go:47:6: func NewLabelsApi should be NewLabelsAPI (ST1003)
api\labels_deprecated.go:61:25: method FindLabelsByOrgId should be FindLabelsByOrgID (ST1003)
api\labels_deprecated.go:65:25: method FindLabelById should be FindLabelByID (ST1003)
api\labels_deprecated.go:69:62: method parameter orgId should be orgID (ST1003)
api\labels_deprecated.go:77:25: method CreateLabelWithNameWithId should be CreateLabelWithNameWithID (ST1003)
api\labels_deprecated.go:77:72: method parameter orgId should be orgID (ST1003)
api\labels_deprecated.go:93:25: method DeleteLabelWithId should be DeleteLabelWithID (ST1003)
api\organizations_deprecated.go:14:6: type OrganizationsApi should be OrganizationsAPI (ST1003)
api\organizations_deprecated.go:20:44: interface method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:32:48: interface method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:36:40: interface method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:40:39: interface method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:40:46: interface method parameter memberId should be memberID (ST1003)
api\organizations_deprecated.go:44:42: interface method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:44:49: interface method parameter memberId should be memberID (ST1003)
api\organizations_deprecated.go:48:39: interface method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:52:38: interface method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:52:45: interface method parameter memberId should be memberID (ST1003)
api\organizations_deprecated.go:56:41: interface method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:56:48: interface method parameter memberId should be memberID (ST1003)
api\organizations_deprecated.go:60:39: interface method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:64:38: interface method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:64:45: interface method parameter labelId should be labelID (ST1003)
api\organizations_deprecated.go:68:41: interface method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:68:48: interface method parameter labelId should be labelID (ST1003)
api\organizations_deprecated.go:71:6: type organizationsApiImpl should be organizationsAPIImpl (ST1003)
api\organizations_deprecated.go:75:1: comment on exported function NewOrganizationsApi should be of the form "NewOrganizationsApi ..." (ST1020)
api\organizations_deprecated.go:76:6: func NewOrganizationsApi should be NewOrganizationsAPI (ST1003)
api\organizations_deprecated.go:90:32: method FindOrganizationById should be FindOrganizationByID (ST1003)
api\organizations_deprecated.go:90:74: method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:94:32: method FindOrganizationsByUserId should be FindOrganizationsByUserID (ST1003)
api\organizations_deprecated.go:110:32: method DeleteOrganizationWithId should be DeleteOrganizationWithID (ST1003)
api\organizations_deprecated.go:110:78: method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:122:32: method GetMembersWithId should be GetMembersWithID (ST1003)
api\organizations_deprecated.go:122:70: method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:130:32: method AddMemberWithId should be AddMemberWithID (ST1003)
api\organizations_deprecated.go:130:69: method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:130:76: method parameter memberId should be memberID (ST1003)
api\organizations_deprecated.go:138:32: method RemoveMemberWithId should be RemoveMemberWithID (ST1003)
api\organizations_deprecated.go:138:72: method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:138:79: method parameter memberId should be memberID (ST1003)
api\organizations_deprecated.go:146:32: method GetOwnersWithId should be GetOwnersWithID (ST1003)
api\organizations_deprecated.go:146:69: method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:154:32: method AddOwnerWithId should be AddOwnerWithID (ST1003)
api\organizations_deprecated.go:154:68: method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:154:75: method parameter ownerId should be ownerID (ST1003)
api\organizations_deprecated.go:162:32: method RemoveOwnerWithId should be RemoveOwnerWithID (ST1003)
api\organizations_deprecated.go:162:71: method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:162:78: method parameter memberId should be memberID (ST1003)
api\organizations_deprecated.go:170:32: method GetLabelsWithId should be GetLabelsWithID (ST1003)
api\organizations_deprecated.go:170:69: method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:178:32: method AddLabelWithId should be AddLabelWithID (ST1003)
api\organizations_deprecated.go:178:68: method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:178:75: method parameter labelId should be labelID (ST1003)
api\organizations_deprecated.go:186:32: method RemoveLabelWithId should be RemoveLabelWithID (ST1003)
api\organizations_deprecated.go:186:71: method parameter orgId should be orgID (ST1003)
api\organizations_deprecated.go:186:78: method parameter memberId should be memberID (ST1003)
api\query_deprecated.go:10:6: type QueryApi should be QueryAPI (ST1003)
api\users_deprecated.go:14:6: type UsersApi should be UsersAPI (ST1003)
api\users_deprecated.go:41:6: type usersApiImpl should be usersAPIImpl (ST1003)
api\users_deprecated.go:45:1: comment on exported function NewUsersApi should be of the form "NewUsersApi ..." (ST1020)
api\users_deprecated.go:46:6: func NewUsersApi should be NewUsersAPI (ST1003)
api\users_deprecated.go:56:24: method FindUserById should be FindUserByID (ST1003)
api\users_deprecated.go:80:24: method UpdateUserPasswordWithId should be UpdateUserPasswordWithID (ST1003)
api\users_deprecated.go:88:24: method DeleteUserWithId should be DeleteUserWithID (ST1003)
api\writeApiBlocking.go:34:1: comment on exported function NewWriteAPIBlocking should be of the form "NewWriteAPIBlocking ..." (ST1020)
api\write_deprecated.go:11:6: type WriteApi should be WriteAPI (ST1003)
api\write_deprecated.go:32:6: type WriteApiBlocking should be WriteAPIBlocking (ST1003)
client.go:100:2: struct field authApi should be authAPI (ST1003)
client.go:102:2: struct field orgApi should be orgAPI (ST1003)
client.go:103:2: struct field usersApi should be usersAPI (ST1003)
client.go:106:2: struct field deleteApi should be deleteAPI (ST1003)
client.go:108:2: struct field bucketsApi should be bucketsAPI (ST1003)
client.go:109:2: struct field labelsApi should be labelsAPI (ST1003)
client.go:116:16: func parameter serverUrl should be serverURL (ST1003)
client.go:149:22: method ServerUrl should be ServerURL (ST1003)
client.go:207:22: method WriteApi should be WriteAPI (ST1003)
client.go:216:22: method WriteApiBlocking should be WriteAPIBlocking (ST1003)
client.go:234:22: method QueryApi should be QueryAPI (ST1003)
client.go:247:22: method AuthorizationsApi should be AuthorizationsAPI (ST1003)
client.go:251:15: api.NewAuthorizationsApi is deprecated: Use NewAuthorizationsAPI instead.  (SA1019)
client.go:265:22: method OrganizationsApi should be OrganizationsAPI (ST1003)
client.go:269:14: api.NewOrganizationsApi is deprecated: use NewOrganizationsAPI instead.  (SA1019)
client.go:283:22: method UsersApi should be UsersAPI (ST1003)
client.go:287:16: api.NewUsersApi is deprecated: use NewUsersAPI instead.  (SA1019)
client.go:301:22: method DeleteApi should be DeleteAPI (ST1003)
client.go:305:17: api.NewDeleteApi is deprecated: Use NewDeleteAPI instead  (SA1019)
client.go:319:22: method BucketsApi should be BucketsAPI (ST1003)
client.go:323:18: api.NewBucketsApi is deprecated: Use NewBucketsAPI instead  (SA1019)
client.go:337:22: method LabelsApi should be LabelsAPI (ST1003)
client.go:341:17: api.NewLabelsApi is deprecated: use NewLabelsAPI instead.  (SA1019)
options.go:120:19: method TlsConfig should be TLSConfig (ST1003)
options.go:132:19: method SetTlsConfig should be SetTLSConfig (ST1003)
options.go:143:19: method HttpRequestTimeout should be HTTPRequestTimeout (ST1003)
options.go:155:19: method SetHttpRequestTimeout should be SetHTTPRequestTimeout (ST1003)
options.go:177:19: method HttpOptions should be HTTPOptions (ST1003)
options_deprecated_test.go:81:2: var queryApi should be queryAPI (ST1003) 

@vlastahajek
Copy link
Contributor Author

In the current state, with the deprecated stuff in, the only CI check to verify this until deprecated stuff is removed I can think of, is to save the current output and compare it each next run?

Copy link
Contributor

@sranka sranka left a comment

Choose a reason for hiding this comment

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

I suggest the following changes so that the review of naming conventions is automated

  • run staticcheck --checks="all" ./... in .circleci/config.yml
  • add //lint:file-ignore ST1003 to be removed in the next release header to every *_deprecated* file
  • ignore specific SA1019 errors with line annotations //lint:ignore SA1019 to be removed in the next release

From my POV, the huge set of changes herein is approved after staticcheck --checks="all" ./... pass

@vlastahajek
Copy link
Contributor Author

Great idea! Implemented. CI now runs checks with staticcheck --checks="all" --tags e2e ./...

@vlastahajek vlastahajek merged commit 372845a into influxdata:master Jul 17, 2020
@vlastahajek vlastahajek deleted the fix/naming-conventions branch July 17, 2020 12:57
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.

Address issues from staticcheck
2 participants