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 coding guideline about constructor due to mock implementation #792

Merged

Conversation

hlts2
Copy link
Collaborator

@hlts2 hlts2 commented Oct 21, 2020

Description:

WHY

  • when I fixed the implementation so that object can be created via interface for mocking, I forgot to fix the constructor.
    So nil pointer exception bug occurs.

WHAT

  • Write a coding guideline about constructor for mocking
    • Constructor method returns an error
    • Field validation in the constructor method (after setting the options)
    • Set the internally generated object with the private unexported option.

Related Card:

https://github.com/vdaas/vald/projects/3#card-47624462

Related Issue:

How Has This Been Tested?:

Environment:

  • Go Version: 1.15.2
  • Docker Version: 19.03.8
  • Kubernetes Version: 1.18.2
  • NGT Version: 1.12.1

Types of changes:

  • Bug fix [type/bug]
  • New feature [type/feature]
  • Add tests [type/test]
  • Security related changes [type/security]
  • Add documents [type/documentation]
  • Refactoring [type/refactoring]
  • Update dependencies [type/dependency]
  • Update benchmarks and performances [type/bench]
  • Update CI [type/ci]

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Checklist:

  • I have read the CONTRIBUTING document.
  • I have checked open Pull Requests for the similar feature or fixes?
  • I have added tests and benchmarks to cover my changes.
  • I have ensured all new and existing tests passed.
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly.

Signed-off-by: hlts2 <hiroto.funakoshi.hiroto@gmail.com>
Signed-off-by: hlts2 <hiroto.funakoshi.hiroto@gmail.com>
@hlts2 hlts2 self-assigned this Oct 21, 2020
@vdaas-ci
Copy link
Collaborator

[CHATOPS:HELP] ChatOps commands.

  • 🙆‍♀️ /approve - approve
  • 💌 /changelog - add changelog comment
  • 🍱 /format - format codes and add licenses
  • /gen-test - generate test codes
  • 🏷️ /label - add labels
  • /rebase - rebase master

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

LanguageTool

docs/contributing/coding-style.md|605 col 6| Don't put a space before the closing parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: }
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|607 col 1| Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Suggestions: func
Rule: https://community.languagetool.org/rule/show/ENGLISH_WORD_REPEAT_RULE?lang=en-US
Category: MISC
docs/contributing/coding-style.md|608 col 22| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: Option
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|608 col 46| Don't put a space after the opening parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: {
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|610 col 53| Don't put a space after the opening parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: {
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|611 col 39| Don't put a space after the opening parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: {
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|612 col 27| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: ErrOptionFailed
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|612 col 56| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: ValueOf
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|613 col 1| Possible typo: you repeated a whitespace (WHITESPACE_RULE)
Suggestions:
Rule: https://community.languagetool.org/rule/show/WHITESPACE_RULE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|614 col 12| This sentence does not start with an uppercase letter (UPPERCASE_SENTENCE_START)
Suggestions: E
Rule: https://community.languagetool.org/rule/show/UPPERCASE_SENTENCE_START?lang=en-US
Category: CASING
docs/contributing/coding-style.md|614 col 28| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: ErrCriticalOption
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|615 col 13| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: As
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|615 col 25| Don't put a space after the opening parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: {
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|616 col 20| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: Error
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|618 col 11| Don't put a space before the closing parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: }
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|619 col 16| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: Warn
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|620 col 7| Don't put a space before the closing parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: }
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|621 col 3| Don't put a space before the closing parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: }
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|622 col 1| Possible typo: you repeated a whitespace (WHITESPACE_RULE)
Suggestions:
Rule: https://community.languagetool.org/rule/show/WHITESPACE_RULE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|623 col 19| Don't put a space before the closing parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: }
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY

docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
@hlts2
Copy link
Collaborator Author

hlts2 commented Oct 26, 2020

/rebase

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by hlts2 for branch: documentation/fix-coding-guidelines-about-constructor

@hlts2 hlts2 changed the title [WIP] Fix coding guidelines about mock Fix coding guidelines about mock Oct 26, 2020
@hlts2 hlts2 marked this pull request as ready for review October 26, 2020 01:16
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
hlts2 and others added 2 commits October 26, 2020 11:25
Co-authored-by: Kevin Diu <kevindiujp@gmail.com>
Co-authored-by: Kevin Diu <kevindiujp@gmail.com>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

LanguageTool

docs/contributing/coding-style.md|605 col 6| Don't put a space before the closing parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: }
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|607 col 1| Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Suggestions: func
Rule: https://community.languagetool.org/rule/show/ENGLISH_WORD_REPEAT_RULE?lang=en-US
Category: MISC
docs/contributing/coding-style.md|608 col 22| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: Option
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|608 col 46| Don't put a space after the opening parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: {
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|610 col 53| Don't put a space after the opening parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: {
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|611 col 39| Don't put a space after the opening parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: {
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|612 col 27| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: ErrOptionFailed
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|612 col 56| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: ValueOf
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|613 col 1| Possible typo: you repeated a whitespace (WHITESPACE_RULE)
Suggestions:
Rule: https://community.languagetool.org/rule/show/WHITESPACE_RULE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|614 col 12| This sentence does not start with an uppercase letter (UPPERCASE_SENTENCE_START)
Suggestions: E
Rule: https://community.languagetool.org/rule/show/UPPERCASE_SENTENCE_START?lang=en-US
Category: CASING
docs/contributing/coding-style.md|614 col 28| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: ErrCriticalOption
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|615 col 13| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: As
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|615 col 25| Don't put a space after the opening parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: {
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|616 col 20| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: Error
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|618 col 11| Don't put a space before the closing parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: }
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|619 col 16| Add a space between sentences (SENTENCE_WHITESPACE)
Suggestions: Warn
Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|620 col 7| Don't put a space before the closing parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: }
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|621 col 3| Don't put a space before the closing parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: }
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|622 col 1| Possible typo: you repeated a whitespace (WHITESPACE_RULE)
Suggestions:
Rule: https://community.languagetool.org/rule/show/WHITESPACE_RULE?lang=en-US
Category: TYPOGRAPHY
docs/contributing/coding-style.md|623 col 19| Don't put a space before the closing parenthesis (COMMA_PARENTHESIS_WHITESPACE)
Suggestions: }
Rule: https://community.languagetool.org/rule/show/COMMA_PARENTHESIS_WHITESPACE?lang=en-US
Category: TYPOGRAPHY

docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
hlts2 and others added 2 commits October 26, 2020 11:32
Co-authored-by: Kevin Diu <kevindiujp@gmail.com>
Co-authored-by: Kevin Diu <kevindiujp@gmail.com>
Signed-off-by: hlts2 <hiroto.funakoshi.hiroto@gmail.com>
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
docs/contributing/coding-style.md Outdated Show resolved Hide resolved
Co-authored-by: Kevin Diu <kevindiujp@gmail.com>
kevindiu
kevindiu previously approved these changes Oct 26, 2020
Copy link
Contributor

@kevindiu kevindiu left a comment

Choose a reason for hiding this comment

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

LGTM

@vankichi
Copy link
Contributor

please fill out description without URL and this PR title does not match your changes.

@hlts2 hlts2 changed the title Fix coding guidelines about mock Fix coding guideline about constructor due to mock implementation Oct 26, 2020
@vankichi
Copy link
Contributor

/rebase
/format
/approve

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by vankichi for branch: documentation/fix-coding-guidelines-about-constructor

@vdaas-ci
Copy link
Collaborator

[FORMAT] Updating license headers and formatting go codes triggered by vankichi.

Copy link
Collaborator

@vdaas-ci vdaas-ci left a comment

Choose a reason for hiding this comment

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

[APPROVED] This PR is approved by vankichi.

@codecov
Copy link

codecov bot commented Oct 26, 2020

Codecov Report

Merging #792 into master will decrease coverage by 0.13%.
The diff coverage is 23.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #792      +/-   ##
==========================================
- Coverage   16.92%   16.79%   -0.14%     
==========================================
  Files         421      421              
  Lines       19528    19534       +6     
==========================================
- Hits         3305     3280      -25     
- Misses      15999    16023      +24     
- Partials      224      231       +7     
Impacted Files Coverage Δ
internal/db/storage/blob/s3/s3.go 0.00% <0.00%> (ø)
pkg/gateway/vald/handler/grpc/handler.go 0.00% <0.00%> (ø)
internal/db/storage/blob/s3/reader/reader.go 65.90% <33.33%> (-34.10%) ⬇️
internal/db/storage/blob/s3/reader/option.go 100.00% <100.00%> (ø)
internal/worker/worker.go 83.33% <0.00%> (+1.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 067e12e...fb9e5fe. Read the comment docs.

@vankichi vankichi merged commit 2ad623d into master Oct 27, 2020
@vankichi vankichi deleted the documentation/fix-coding-guidelines-about-constructor branch October 27, 2020 07:48
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.

4 participants