mirror of
https://github.com/mgechev/revive.git
synced 2025-11-25 22:12:38 +02:00
Add check for argument length to "file-header" rule
This commit is contained in:
@@ -16,9 +16,13 @@ var (
|
|||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
func (r *FileHeaderRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure {
|
func (r *FileHeaderRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure {
|
||||||
|
if len(arguments) != 1 {
|
||||||
|
panic(`invalid configuration for "file-header" rule`)
|
||||||
|
}
|
||||||
|
|
||||||
header, ok := arguments[0].(string)
|
header, ok := arguments[0].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("Invalid argument to the FileHeaderRule")
|
panic(`invalid argument for "file-header" rule: first argument should be a string`)
|
||||||
}
|
}
|
||||||
|
|
||||||
failure := []lint.Failure{
|
failure := []lint.Failure{
|
||||||
|
|||||||
Reference in New Issue
Block a user