代码拉取完成,页面将自动刷新
package main
import (
"bufio"
"fmt"
"regexp"
"strings"
"github.com/nokia/ntt/ttcn3/syntax"
)
var (
nolintRegex = regexp.MustCompile(`^[/*\s]*NOLINT\(([^\)]+)\)[/*\r\n\s]*$`)
)
type errPattern struct {
node syntax.Node
msg string
}
func (e errPattern) Error() string {
return fmt.Sprintf("%s:%s: error: %s", syntax.Filename(e.node), syntax.Begin(e.node), e.msg)
}
func (e errPattern) IsSilent() bool { return isSilent(e.node, "TemplateDef") }
type errLines struct {
node syntax.Node
lines int
}
func (e errLines) Error() string {
return fmt.Sprintf("%s:%s: error: %q must not have more than %d lines (%d)",
syntax.Filename(e.node), syntax.Begin(e.node), syntax.Name(e.node), style.MaxLines, e.lines)
}
func (e errLines) IsSilent() bool { return isSilent(e.node, "CodeStatistics.TooLong") }
type errBraces struct {
left, right syntax.Node
}
func (e errBraces) Error() string {
return fmt.Sprintf("%s:%s: error: braces must be in the same line or same column",
syntax.Filename(e.right), syntax.Begin(e.right))
}
type errComplexity struct {
node syntax.Node
complexity int
}
func (e errComplexity) Error() string {
return fmt.Sprintf("%s:%s: error: cyclomatic complexity of %q (%d) must not be higher than %d",
syntax.Filename(e.node), syntax.Begin(e.node), syntax.Name(e.node), e.complexity, style.Complexity.Max)
}
func (e errComplexity) IsSilent() bool { return isSilent(e.node, "CodeStatistics.TooComplex") }
type errMissingCaseElse struct {
node syntax.Node
}
func (e errMissingCaseElse) Error() string {
return fmt.Sprintf("%s:%s: error: missing case else in select statement", syntax.Filename(e.node), syntax.Begin(e.node))
}
type errUsageExceedsLimit struct {
node syntax.Node
usage int
limit int
text string
}
func (e errUsageExceedsLimit) Error() string {
return fmt.Sprintf("%s:%s: error: %q must not be used more than %d times. %s",
syntax.Filename(e.node), syntax.Begin(e.node), syntax.Name(e.node), e.limit, e.text)
}
type errUnusedModule struct {
file string
name string
}
func (e errUnusedModule) Error() string {
return fmt.Sprintf("%s: error: unused module %q", e.file, e.name)
}
func isSilent(n syntax.Node, checks ...string) bool {
scanner := bufio.NewScanner(strings.NewReader(syntax.Doc(n)))
for scanner.Scan() {
if s := nolintRegex.FindStringSubmatch(scanner.Text()); len(s) == 2 {
for _, s := range strings.Split(s[1], ",") {
if searchString(checks, s) {
return true
}
}
}
}
return false
}
func searchString(slice []string, s string) bool {
for _, s2 := range slice {
if strings.TrimSpace(s) == strings.TrimSpace(s2) {
return true
}
}
return false
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。