1set/starlet

View on GitHub

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)
Severity: Minor
Found in dataconv/marshal.go - About 1 day to fix

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.
Severity: Minor
Found in lib/http/http.go - About 1 day to fix

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)
Severity: Major
Found in dataconv/marshal.go - About 5 hrs to fix

    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
    Severity: Minor
    Found in lib/random/random.go - About 3 hrs to fix

    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
    Severity: Minor
    Found in machine.go - About 3 hrs to fix

      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:
      Severity: Minor
      Found in dataconv/marshal.go - About 2 hrs to fix

      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.
      Severity: Major
      Found in lib/http/http.go - About 2 hrs to fix

        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:
        Severity: Major
        Found in dataconv/marshal.go - About 2 hrs to fix

          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
          Severity: Major
          Found in lib/random/random.go - About 2 hrs to fix

            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)
                    }
            Severity: Minor
            Found in run.go - About 2 hrs to fix

            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)
                    }
            Severity: Minor
            Found in run.go - About 1 hr to fix

              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()
              Severity: Minor
              Found in cmd/starlet/main.go - About 1 hr to fix

                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)
                Severity: Major
                Found in dataconv/marshal.go - About 1 hr to fix

                  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
                  Severity: Major
                  Found in lib/random/random.go - About 1 hr to fix

                    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
                    Severity: Minor
                    Found in lib/csv/csv.go - About 1 hr to fix

                      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
                      Severity: Minor
                      Found in lib/http/http.go - About 1 hr to fix

                        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
                        Severity: Minor
                        Found in lib/csv/csv.go - About 1 hr to fix

                          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 {
                          Severity: Minor
                          Found in internal/testloader.go - About 1 hr to fix

                          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{}
                          Severity: Major
                          Found in lib/path/path.go - About 1 hr to fix

                            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())
                            Severity: Minor
                            Found in lib/log/zaplog.go - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language