Showing 51 of 84 total issues
Function setBody
has 11 return statements (exceeds 4 allowed). Open
Open
func setBody(req *http.Request, body *types.NullableStringOrBytes, formData *starlark.Dict, formEncoding starlark.String, jsonData starlark.Value) error {
if !body.IsNullOrEmpty() {
uq := body.GoString()
req.Body = ioutil.NopCloser(strings.NewReader(uq))
// Specifying the Content-Length ensures that https://go.dev/src/net/http/transfer.go doesnt specify Transfer-Encoding: chunked which is not supported by some endpoints.
Function copyFileGo
has 11 return statements (exceeds 4 allowed). Open
Open
func copyFileGo(src, dst string, overwrite bool) (string, error) {
// No empty input
if src == emptyStr {
return emptyStr, errors.New("source path is empty")
}
Method Machine.prepareThread
has 10 return statements (exceeds 4 allowed). Open
Open
func (m *Machine) prepareThread(extras StringAnyMap) (err error) {
mergeExtra := func() error {
// no extras
if extras == nil {
return nil
Function writeDict
has 9 return statements (exceeds 4 allowed). Open
Open
func writeDict(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var (
buf = &bytes.Buffer{}
data starlark.Value
header starlark.Iterable
Function Marshal
has 8 return statements (exceeds 4 allowed). Open
Open
func Marshal(data interface{}) (v starlark.Value, err error) {
switch x := data.(type) {
case nil:
v = starlark.None
case bool:
Function shuffle
has 8 return statements (exceeds 4 allowed). Open
Open
func shuffle(thread *starlark.Thread, bn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
// precondition checks
var seq starlark.HasSetIndex
if err := starlark.UnpackArgs(bn.Name(), args, kwargs, "seq", &seq); err != nil {
return nil, err
Function ExecModuleWithErrorTest
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func ExecModuleWithErrorTest(t *testing.T, name string, loader ModuleLoadFunc, script string, wantErr string, predecl starlark.StringDict) (starlark.StringDict, error) {
Function setQueryParams
has 7 return statements (exceeds 4 allowed). Open
Open
func setQueryParams(rawurl *string, params *starlark.Dict) error {
keys := params.Keys()
if len(keys) == 0 {
return nil
}
Avoid deeply nested control flow statements. Open
Open
} else if sm, ok := m.(*starlarkstruct.Struct); ok && sm != nil {
sd := make(starlark.StringDict)
sm.ToStringDict(sd)
return sd, nil
}
Function processArgs
has 7 return statements (exceeds 4 allowed). Open
Open
func processArgs() int {
// get starlet machine
mac := starlet.NewWithNames(nil, preloadModules, lazyLoadModules)
if allowRecursion {
mac.EnableRecursionSupport()
Function writeAll
has 7 return statements (exceeds 4 allowed). Open
Open
func writeAll(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var (
buf = &bytes.Buffer{}
data starlark.Value
comma string
Method Module.reqMethod
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (m *Module) reqMethod(method string) func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
return func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var (
getDefaultDict = func() *types.NullableDict { return types.NewNullableDict(starlark.NewDict(0)) }
urlv starlark.String
- 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
Method Machine.Call
has 7 return statements (exceeds 4 allowed). Open
Open
func (m *Machine) Call(name string, args ...interface{}) (out interface{}, err error) {
m.mu.Lock()
defer m.mu.Unlock()
defer func() {
Function TypeConvert
has 7 return statements (exceeds 4 allowed). Open
Open
func TypeConvert(data interface{}) interface{} {
switch v := data.(type) {
case string:
// Attempt parsing in different formats
for _, format := range []string{time.RFC3339, time.RFC3339Nano, time.RFC822, time.RFC1123} {
Method Machine.runInternal
has 6 return statements (exceeds 4 allowed). Open
Open
func (m *Machine) runInternal(ctx context.Context, extras StringAnyMap, allowCache bool) (out StringAnyMap, err error) {
defer func() {
if r := recover(); r != nil {
err = errorStarlarkPanic("exec", r)
}
Function readAll
has 6 return statements (exceeds 4 allowed). Open
Open
func readAll(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var (
source tps.StringOrBytes
lazyQuotes, trimLeadingSpace bool
skipRow, limitRow int
Function goPingWrap
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func goPingWrap(ctx context.Context, address string, count int, timeout, interval time.Duration, pingFunc func(ctx context.Context, address string, timeout time.Duration) (time.Duration, error)) ([]time.Duration, error) {
Function setBody
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func setBody(req *http.Request, body *types.NullableStringOrBytes, formData *starlark.Dict, formEncoding starlark.String, jsonData starlark.Value) error {
Function extractIOBottomLines
has 5 return statements (exceeds 4 allowed). Open
Open
func extractIOBottomLines(rd io.Reader, n int) ([]string, error) {
if n <= 0 {
return nil, errors.New("n should be greater than 0")
}
var (
Method SharedDict.LoadJSON
has 5 return statements (exceeds 4 allowed). Open
Open
func (s *SharedDict) LoadJSON(jsonStr string) error {
// check the dict itself
if s == nil {
return fmt.Errorf("nil shared dict")
}