mirror of
				https://github.com/mgechev/revive.git
				synced 2025-10-30 23:37:49 +02:00 
			
		
		
		
	chore: update golangci-lint; enable a few revive rules (#1420)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
		
							
								
								
									
										2
									
								
								.github/workflows/lint.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/lint.yaml
									
									
									
									
										vendored
									
									
								
							| @@ -54,7 +54,7 @@ jobs: | ||||
|     - name: Run golangci-lint | ||||
|       uses: golangci/golangci-lint-action@v8 | ||||
|       with: | ||||
|         version: v2.1.6 | ||||
|         version: v2.2.1 | ||||
|  | ||||
|   lint-md: | ||||
|     name: Lint Markdown | ||||
|   | ||||
| @@ -46,6 +46,7 @@ linters: | ||||
|         - name: constant-logical-expr | ||||
|         - name: context-as-argument | ||||
|         - name: context-keys-type | ||||
|         - name: datarace | ||||
|         - name: deep-exit | ||||
|         - name: dot-imports | ||||
|         - name: empty-block | ||||
| @@ -73,15 +74,19 @@ linters: | ||||
|         - name: redefines-builtin-id | ||||
|         - name: redundant-build-tag | ||||
|         - name: superfluous-else | ||||
|         - name: time-date | ||||
|         - name: time-equal | ||||
|         - name: time-naming | ||||
|         - name: unexported-naming | ||||
|         - name: unexported-return | ||||
|         - name: unnecessary-format | ||||
|         - name: unnecessary-stmt | ||||
|         - name: unreachable-code | ||||
|         - name: unused-parameter | ||||
|         - name: unused-receiver | ||||
|         - name: useless-break | ||||
|         - name: use-any | ||||
|         - name: use-fmt-print | ||||
|         - name: var-declaration | ||||
|         - name: var-naming | ||||
|  | ||||
|   | ||||
| @@ -31,7 +31,7 @@ func TestRetrieveModFile(t *testing.T) { | ||||
| 	t.Run("go.mod file does not exist", func(t *testing.T) { | ||||
| 		_, err := retrieveModFile(t.TempDir()) | ||||
| 		if err == nil { | ||||
| 			t.Fatalf("expected error, got nil") | ||||
| 			t.Fatal("expected error, got nil") | ||||
| 		} | ||||
| 		expectedErrMsg := `did not found "go.mod" file` | ||||
| 		if err.Error() != expectedErrMsg { | ||||
|   | ||||
| @@ -13,6 +13,7 @@ warningCode = 1 | ||||
| [rule.constant-logical-expr] | ||||
| [rule.context-as-argument] | ||||
| [rule.context-keys-type] | ||||
| [rule.datarace] | ||||
| [rule.deep-exit] | ||||
| [rule.dot-imports] | ||||
| [rule.empty-block] | ||||
| @@ -40,14 +41,18 @@ warningCode = 1 | ||||
| [rule.redefines-builtin-id] | ||||
| [rule.redundant-build-tag] | ||||
| [rule.superfluous-else] | ||||
| [rule.time-date] | ||||
| [rule.time-equal] | ||||
| [rule.time-naming] | ||||
| [rule.unexported-naming] | ||||
| [rule.unexported-return] | ||||
| [rule.unnecessary-format] | ||||
| [rule.unnecessary-stmt] | ||||
| [rule.unreachable-code] | ||||
| [rule.unused-parameter] | ||||
| [rule.unused-receiver] | ||||
| [rule.useless-break] | ||||
| [rule.use-any] | ||||
| [rule.use-fmt-print] | ||||
| [rule.var-declaration] | ||||
| [rule.var-naming] | ||||
|   | ||||
| @@ -126,8 +126,13 @@ func (r *Revive) Format( | ||||
| 		return "", 0, fmt.Errorf("formatting - getting formatter: %w", err) | ||||
| 	} | ||||
|  | ||||
| 	var ( | ||||
| 		out       string | ||||
| 		formatErr error | ||||
| 	) | ||||
|  | ||||
| 	go func() { | ||||
| 		output, err = formatter.Format(formatChan, *conf) | ||||
| 		out, formatErr = formatter.Format(formatChan, *conf) | ||||
|  | ||||
| 		exitChan <- true | ||||
| 	}() | ||||
| @@ -155,11 +160,11 @@ func (r *Revive) Format( | ||||
| 	close(formatChan) | ||||
| 	<-exitChan | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return "", exitCode, fmt.Errorf("formatting: %w", err) | ||||
| 	if formatErr != nil { | ||||
| 		return "", exitCode, fmt.Errorf("formatting: %w", formatErr) | ||||
| 	} | ||||
|  | ||||
| 	return output, exitCode, nil | ||||
| 	return out, exitCode, nil | ||||
| } | ||||
|  | ||||
| func getPackages(includePatterns []string, excludePatterns ArrayFlags) ([][]string, error) { | ||||
|   | ||||
| @@ -113,9 +113,6 @@ func checkMethodName(holder string, id *ast.Ident, w *lintConfusingNames) { | ||||
| 	} | ||||
|  | ||||
| 	// update the block list | ||||
| 	if pkgm.methods[holder] == nil { | ||||
| 		println("no entry for '", holder, "'") | ||||
| 	} | ||||
| 	pkgm.methods[holder][name] = &referenceMethod{fileName: w.fileName, id: id} | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user