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

chore: minor code cleanup #134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tomiok
Copy link

@tomiok tomiok commented Dec 10, 2024

_ remove re assignation in errors
_ do not use defer inside a for loop by extracting in other func
_ replace fmt.Errorf with errors.New since the err was only a string.

Copy link
Contributor

@alexanderguy alexanderguy left a comment

Choose a reason for hiding this comment

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

Thank you very much for this PR! I left a note, and I had some feedback on the commit structure. We use rebases and smaller specific commits on this project. Looking at this PR I'd like to see it split up into several independent commits:

  • Change the const naming convention
  • fmt.Errorf -> errors.New
  • copyFile refactor to avoid defer in loop
  • res var vs. assignment
  • use os.FileMode
  • Reuse err rather shadow it

If you don't have time to do the rearranging, let me know and we can help take care of it.

@@ -19,47 +20,47 @@ type ValidatorInfo struct {
}

func (i *ValidatorInfo) Check() error {
if len(i.Name) > MAX_SHORT_FIELD_LENGTH {
return fmt.Errorf("name exceeds maximum length of %d", MAX_SHORT_FIELD_LENGTH)
if utf8.RuneCountInString(i.Name) > MaxShortFieldLength {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I haven't looked, but have you double checked that the validator length limits are based on UTF-8 runes, rather than just bytes?

Copy link
Contributor

Choose a reason for hiding this comment

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

@alexanderguy
Copy link
Contributor

Hey @tomiok just a bump on this. Let me know if you don't have the bandwidth, and we can take care of merging most of these changes in. Thanks.

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.

3 participants