mirror of
				https://github.com/mgechev/revive.git
				synced 2025-10-30 23:37:49 +02:00 
			
		
		
		
	exported: ignore exported symbols from the main package (#1398)
This commit is contained in:
		| @@ -110,11 +110,11 @@ func (r *ExportedRule) Configure(arguments lint.Arguments) error { | ||||
|  | ||||
| // Apply applies the rule to given file. | ||||
| func (r *ExportedRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { | ||||
| 	var failures []lint.Failure | ||||
| 	if file.IsTest() { | ||||
| 		return failures | ||||
| 	if !file.IsImportable() { | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	var failures []lint.Failure | ||||
| 	walker := lintExported{ | ||||
| 		file: file, | ||||
| 		onFailure: func(failure lint.Failure) { | ||||
|   | ||||
| @@ -47,3 +47,7 @@ func TestCheckDirectiveComment(t *testing.T) { | ||||
| func TestCheckDeprecationComment(t *testing.T) { | ||||
| 	testRule(t, "exported_issue_1231", &rule.ExportedRule{}, &lint.RuleConfig{}) | ||||
| } | ||||
|  | ||||
| func TestExportedMainPackage(t *testing.T) { | ||||
| 	testRule(t, "exported_main", &rule.ExportedRule{}, &lint.RuleConfig{}) | ||||
| } | ||||
|   | ||||
							
								
								
									
										4
									
								
								testdata/exported_main.go
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								testdata/exported_main.go
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| // Symbols declared in main package cannot be imported. | ||||
| package main | ||||
|  | ||||
| type Foo struct{} | ||||
		Reference in New Issue
	
	Block a user