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

Panic when contains empty type block declaration #792

Closed
QuangTung97 opened this issue Feb 17, 2023 · 3 comments · Fixed by #793
Closed

Panic when contains empty type block declaration #792

QuangTung97 opened this issue Feb 17, 2023 · 3 comments · Fixed by #793
Labels

Comments

@QuangTung97
Copy link

QuangTung97 commented Feb 17, 2023

Describe the bug
revive panics when the source code contains
type ()

To Reproduce
Steps to reproduce the behavior:

  1. I install revive v1.2.4
  2. Write Program with type () declaration
  3. Run revive -config revive.toml -formatter friendly ./...

Panic happened in the line:
github.com/mgechev/revive@v1.2.4/rule/redefines-builtin-id.go:92

Expected behavior
Should not panics without any meaningful messages.

Desktop (please complete the following information):

  • OS: [e.g. Ubuntu 20.04]
  • go1.19.4 linux/amd64
@QuangTung97
Copy link
Author

QuangTung97 commented Feb 17, 2023

My revive.toml file

severity = "error"
confidence = 0.8

# Sets the error code for failures with severity "error"
errorCode = 2
# Sets the error code for failures with severity "warning"
warningCode = 1

# Enable all available rules
enableAllRules = true

# Disabled rules
[rule.file-header]
Disabled = true
[rule.max-public-structs]
Disabled = true
[rule.function-length]
Disabled = true
[rule.add-constant]
Disabled = true
[rule.banned-characters]
Disabled = true
[rule.package-comments]
Disabled = true
[rule.use-any]
Disabled = true

# Rule tuning
[rule.argument-limit]
Arguments = [6]
[rule.cyclomatic]
Arguments = [18]
[rule.cognitive-complexity]
Arguments = [20]
[rule.function-result-limit]
Arguments = [4]
[rule.unhandled-error]
Arguments = ["fmt.Printf", "fmt.Println", "buf.WriteString", "buf.Write", "buf.WriteByte", "body.WriteString"]
[rule.line-length-limit]
Arguments = [120]
[rule.defer]
Arguments = [["loop", "method-call", "recover", "return"]]

@QuangTung97
Copy link
Author

Simple go file that causes problem:

package hello

import "fmt"

type ()

func helloWorld() {
	fmt.Println("Hello World")
}

@QuangTung97 QuangTung97 changed the title Panic when empty type block declaration Panic when contains empty type block declaration Feb 17, 2023
chavacava added a commit that referenced this issue Feb 18, 2023
chavacava added a commit that referenced this issue Feb 18, 2023
@chavacava
Copy link
Collaborator

Hi @QuangTung97, thanks for filling the issue.
The PR #793 fixes the problem.

@chavacava chavacava added the bug label Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants