1set/starlet

View on GitHub

Showing 43 of 76 total issues

Function Unmarshal has a Cognitive Complexity of 81 (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 184 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 6 hrs to fix

    Machine has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type Machine struct {
        mu sync.RWMutex
        // set variables
        globals             StringAnyMap
        preloadMods         ModuleLoaderList
    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

          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 19 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 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

                  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

                    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 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

                      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

                        Function setBody has 11 return statements (exceeds 4 allowed).
                        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 1 hr to fix

                          Function copyFileGo has 11 return statements (exceeds 4 allowed).
                          Open

                          func copyFileGo(src, dst string, overwrite bool) (string, error) {
                              // No empty input
                              if src == emptyStr {
                                  return emptyStr, errors.New("source path is empty")
                              }
                          Severity: Major
                          Found in lib/file/copy.go - About 1 hr to fix

                            Method Machine.prepareThread has 10 return statements (exceeds 4 allowed).
                            Open

                            func (m *Machine) prepareThread(extras StringAnyMap) (err error) {
                                mergeExtra := func() error {
                                    // no extras
                                    if extras == nil {
                                        return nil
                            Severity: Major
                            Found in run.go - About 1 hr to fix

                              Function listDirContents has 9 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
                                  )
                              Severity: Major
                              Found in lib/path/path.go - About 55 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language