Showing 51 of 84 total issues
Function Unmarshal
has a Cognitive Complexity of 76 (exceeds 20 allowed). Consider refactoring. Open
func Unmarshal(x starlark.Value) (val interface{}, err error) {
iterAttrs := func(v starlark.HasAttrs) (map[string]interface{}, error) {
jo := make(map[string]interface{})
for _, name := range v.AttrNames() {
sv, err := v.Attr(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 setBody
has a Cognitive Complexity of 67 (exceeds 20 allowed). Consider refactoring. 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.
- 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 Unmarshal
has 174 lines of code (exceeds 50 allowed). Consider refactoring. Open
func Unmarshal(x starlark.Value) (val interface{}, err error) {
iterAttrs := func(v starlark.HasAttrs) (map[string]interface{}, error) {
jo := make(map[string]interface{})
for _, name := range v.AttrNames() {
sv, err := v.Attr(name)
Function choices
has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring. Open
func choices(thread *starlark.Thread, bn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var (
population starlark.Indexable
weights *starlark.List
cumWeights *starlark.List
- 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
Machine
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
type Machine struct {
_ itn.DoNotCompare
mu sync.RWMutex
// set variables
globals StringAnyMap
Function Marshal
has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring. Open
func Marshal(data interface{}) (v starlark.Value, err error) {
switch x := data.(type) {
case nil:
v = starlark.None
case bool:
- 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 setBody
has 97 lines of code (exceeds 50 allowed). Consider refactoring. 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 Marshal
has 95 lines of code (exceeds 50 allowed). Consider refactoring. Open
func Marshal(data interface{}) (v starlark.Value, err error) {
switch x := data.(type) {
case nil:
v = starlark.None
case bool:
Function choices
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
func choices(thread *starlark.Thread, bn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var (
population starlark.Indexable
weights *starlark.List
cumWeights *starlark.List
Method Machine.runInternal
has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring. 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)
}
- 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.runInternal
has 73 lines of code (exceeds 50 allowed). Consider refactoring. 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 processArgs
has 70 lines of code (exceeds 50 allowed). Consider refactoring. Open
func processArgs() int {
// get starlet machine
mac := starlet.NewWithNames(nil, preloadModules, lazyLoadModules)
if allowRecursion {
mac.EnableRecursionSupport()
Function Unmarshal
has 17 return statements (exceeds 4 allowed). Open
func Unmarshal(x starlark.Value) (val interface{}, err error) {
iterAttrs := func(v starlark.HasAttrs) (map[string]interface{}, error) {
jo := make(map[string]interface{})
for _, name := range v.AttrNames() {
sv, err := v.Attr(name)
Function choices
has 14 return statements (exceeds 4 allowed). Open
func choices(thread *starlark.Thread, bn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var (
population starlark.Indexable
weights *starlark.List
cumWeights *starlark.List
Function readAll
has 58 lines of code (exceeds 50 allowed). Consider refactoring. 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
Method Module.reqMethod
has 57 lines of code (exceeds 50 allowed). Consider refactoring. 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
Function writeDict
has 57 lines of code (exceeds 50 allowed). Consider refactoring. 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 NewAssertLoader
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func NewAssertLoader(moduleName string, loader ModuleLoadFunc) ThreadLoadFunc {
initTestOnce.Do(func() {
starlarktest.DataFile = func(pkgdir, filename string) string {
_, currFileName, _, ok := runtime.Caller(1)
if !ok {
- 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 listDirContents
has 12 return statements (exceeds 4 allowed). Open
func listDirContents(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var (
path string
recursive bool
filterFunc = tps.NullableCallable{}
Method Module.genLoggerBuiltin
has 54 lines of code (exceeds 50 allowed). Consider refactoring. 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())