1set/starlet

View on GitHub

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

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

      func length(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
          if l := len(args); l != 1 {
              return none, fmt.Errorf(`length() takes exactly one argument (%d given)`, l)
          }
      
      
      Severity: Major
      Found in lib/goidiomatic/idiomatic.go and 1 other location - About 2 hrs to fix
      lib/string/string.go on lines 87..103

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

      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

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

      func length(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
          if l := len(args); l != 1 {
              return none, fmt.Errorf(`length() takes exactly one argument (%d given)`, l)
          }
      
      
      Severity: Major
      Found in lib/string/string.go and 1 other location - About 2 hrs to fix
      lib/goidiomatic/idiomatic.go on lines 128..144

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

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

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

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

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

                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 floatSub(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
                    var delta tps.FloatOrInt
                    if err := starlark.UnpackArgs(b.Name(), args, kwargs, "delta", &delta); err != nil {
                        return nil, err
                    }
                Severity: Major
                Found in lib/atom/method.go and 1 other location - About 1 hr to fix
                lib/atom/method.go on lines 122..129

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

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

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

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

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

                  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 intCAS(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
                      var oldVal, newVal int64
                      if err := starlark.UnpackArgs(b.Name(), args, kwargs, "old", &oldVal, "new", &newVal); err != nil {
                          return nil, err
                      }
                  Severity: Major
                  Found in lib/atom/method.go and 1 other location - About 1 hr to fix
                  lib/atom/method.go on lines 168..175

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

                  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 intAdd(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
                      var delta int64
                      if err := starlark.UnpackArgs(b.Name(), args, kwargs, "delta", &delta); err != nil {
                          return nil, err
                      }
                  Severity: Major
                  Found in lib/atom/method.go and 1 other location - About 1 hr to fix
                  lib/atom/method.go on lines 58..65

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language