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