You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

generated.go 509B

123456789101112131415161718192021222324252627
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package analyze
  4. import (
  5. "path/filepath"
  6. "strings"
  7. "github.com/go-enry/go-enry/v2/data"
  8. )
  9. // IsGenerated returns whether or not path is a generated path.
  10. func IsGenerated(path string) bool {
  11. ext := strings.ToLower(filepath.Ext(path))
  12. if _, ok := data.GeneratedCodeExtensions[ext]; ok {
  13. return true
  14. }
  15. for _, m := range data.GeneratedCodeNameMatchers {
  16. if m(path) {
  17. return true
  18. }
  19. }
  20. return false
  21. }