1set/starlet

View on GitHub

Showing 84 of 84 total issues

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func newString(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
          var value string
          if err := starlark.UnpackArgs(b.Name(), args, kwargs, "value?", &value); err != nil {
              return nil, err
          }
      Severity: Major
      Found in lib/atom/atom.go and 1 other location - About 1 hr to fix
      lib/atom/atom.go on lines 50..56

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 137.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func newInt(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
          var value int64
          if err := starlark.UnpackArgs(b.Name(), args, kwargs, "value?", &value); err != nil {
              return nil, err
          }
      Severity: Major
      Found in lib/atom/atom.go and 1 other location - About 1 hr to fix
      lib/atom/atom.go on lines 186..192

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 137.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          func hex(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
              var x starlark.Int
              if err := starlark.UnpackArgs(b.Name(), args, kwargs, "x", &x); err != nil {
                  return none, err
              }
          Severity: Major
          Found in lib/goidiomatic/idiomatic.go and 2 other locations - About 1 hr to fix
          lib/goidiomatic/idiomatic.go on lines 220..226
          lib/goidiomatic/idiomatic.go on lines 229..235

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 132.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          func oct(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
              var x starlark.Int
              if err := starlark.UnpackArgs(b.Name(), args, kwargs, "x", &x); err != nil {
                  return none, err
              }
          Severity: Major
          Found in lib/goidiomatic/idiomatic.go and 2 other locations - About 1 hr to fix
          lib/goidiomatic/idiomatic.go on lines 211..217
          lib/goidiomatic/idiomatic.go on lines 229..235

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 132.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          func bin(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
              var x starlark.Int
              if err := starlark.UnpackArgs(b.Name(), args, kwargs, "x", &x); err != nil {
                  return none, err
              }
          Severity: Major
          Found in lib/goidiomatic/idiomatic.go and 2 other locations - About 1 hr to fix
          lib/goidiomatic/idiomatic.go on lines 211..217
          lib/goidiomatic/idiomatic.go on lines 220..226

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 132.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        if len(d) == 1 {
                            m, found := d[moduleName]
                            if found {
                                if mm, ok := m.(*starlarkstruct.Module); ok && mm != nil {
                                    return mm.Members, nil
            Severity: Minor
            Found in internal/testloader.go and 1 other location - About 1 hr to fix
            module.go on lines 134..145

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 129.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    if len(d) == 1 {
                        m, found := d[s]
                        if found {
                            if mm, ok := m.(*starlarkstruct.Module); ok && mm != nil {
                                return mm.Members, nil
            Severity: Minor
            Found in module.go and 1 other location - About 1 hr to fix
            internal/testloader.go on lines 50..61

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 129.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function writeDict has 9 return statements (exceeds 4 allowed).
            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: Major
            Found in lib/csv/csv.go - About 55 mins to fix

              Function Marshal has 8 return statements (exceeds 4 allowed).
              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 50 mins to fix

                Function shuffle has 8 return statements (exceeds 4 allowed).
                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
                Severity: Major
                Found in lib/random/random.go - About 50 mins to fix

                  Function ExecModuleWithErrorTest has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func ExecModuleWithErrorTest(t *testing.T, name string, loader ModuleLoadFunc, script string, wantErr string, predecl starlark.StringDict) (starlark.StringDict, error) {
                  Severity: Minor
                  Found in internal/testloader.go - About 45 mins to fix

                    Function setQueryParams has 7 return statements (exceeds 4 allowed).
                    Open

                    func setQueryParams(rawurl *string, params *starlark.Dict) error {
                        keys := params.Keys()
                        if len(keys) == 0 {
                            return nil
                        }
                    Severity: Major
                    Found in lib/http/http.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          } else if sm, ok := m.(*starlarkstruct.Struct); ok && sm != nil {
                                              sd := make(starlark.StringDict)
                                              sm.ToStringDict(sd)
                                              return sd, nil
                                          }
                      Severity: Major
                      Found in internal/testloader.go - About 45 mins to fix

                        Function processArgs has 7 return statements (exceeds 4 allowed).
                        Open

                        func processArgs() int {
                            // get starlet machine
                            mac := starlet.NewWithNames(nil, preloadModules, lazyLoadModules)
                            if allowRecursion {
                                mac.EnableRecursionSupport()
                        Severity: Major
                        Found in cmd/starlet/main.go - About 45 mins to fix

                          Function writeAll has 7 return statements (exceeds 4 allowed).
                          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
                          Severity: Major
                          Found in lib/csv/csv.go - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language