Showing 51 of 84 total issues
Function starTCPPing
has 5 return statements (exceeds 4 allowed). Open
Open
func starTCPPing(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var (
hostname tps.StringOrBytes
port = 80
count = 4
Function setAuth
has 5 return statements (exceeds 4 allowed). Open
Open
func setAuth(req *http.Request, auth starlark.Tuple) error {
if len(auth) == 0 {
return nil
} else if len(auth) == 2 {
username, err := AsString(auth[0])
Function httpPingFunc
has 5 return statements (exceeds 4 allowed). Open
Open
func httpPingFunc(ctx context.Context, url string, timeout time.Duration) (time.Duration, error) {
// create a custom http client tracing
var (
onceStart, onceDone sync.Once
connStart time.Time
Function readJSONL
has 5 return statements (exceeds 4 allowed). Open
Open
func readJSONL(name string) (starlark.Value, error) {
var (
cnt int
values []starlark.Value
)
Function extractIOTopLines
has 5 return statements (exceeds 4 allowed). Open
Open
func extractIOTopLines(rd io.Reader, n int) ([]string, error) {
if n <= 0 {
return nil, errors.New("n should be greater than 0")
}
result := make([]string, 0)
Function setHeaders
has 5 return statements (exceeds 4 allowed). Open
Open
func setHeaders(req *http.Request, headers *starlark.Dict) error {
var (
keys = headers.Keys()
UAKey = "User-Agent"
isUASet = false
Method cache.doLoad
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *cache) doLoad(cc *cycleChecker, module string) (starlark.StringDict, error) {
thread := &starlark.Thread{
Print: func(_ *starlark.Thread, msg string) { fmt.Println(msg) },
Load: func(_ *starlark.Thread, module string) (starlark.StringDict, error) {
// Tunnel the cycle-checker state for this "thread of loading".
Function convertToDict
has 5 return statements (exceeds 4 allowed). Open
Open
func convertToDict(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var v starlark.Value
if err := starlark.UnpackArgs(b.Name(), args, kwargs, "v", &v); err != nil {
return nil, err
}
Function sharedDictFromJSON
has 5 return statements (exceeds 4 allowed). Open
Open
func sharedDictFromJSON(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
// check the arguments
var s tps.StringOrBytes
if err := starlark.UnpackArgs(b.Name(), args, kwargs, "x", &s); err != nil {
return nil, err
Method Module.genLoggerBuiltin
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (m *Module) genLoggerBuiltin(name string, level zapcore.Level) starlark.Callable {
return starlark.NewBuiltin(ModuleName+"."+name, func(thread *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var msg string
if len(args) <= 0 {
return nil, fmt.Errorf("%s: expected at least 1 argument, got 0", fn.Name())
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function processArgs
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func processArgs() int {
// get starlet machine
mac := starlet.NewWithNames(nil, preloadModules, lazyLoadModules)
if allowRecursion {
mac.EnableRecursionSupport()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"