1set/starlet

View on GitHub

Showing 84 of 84 total issues

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

func search(thread *starlark.Thread, bn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
    var (
        pattern, str starlark.String
        flags        starlark.Int
    )
Severity: Minor
Found in lib/re/re.go and 1 other location - About 45 mins to fix
lib/re/re.go on lines 112..127

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

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 match(thread *starlark.Thread, bn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
    var (
        pattern, str starlark.String
        flags        starlark.Int
    )
Severity: Minor
Found in lib/re/re.go and 1 other location - About 45 mins to fix
lib/re/re.go on lines 76..90

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

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 Module.reqMethod has a Cognitive Complexity of 23 (exceeds 20 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 45 mins 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.Call has 7 return statements (exceeds 4 allowed).
Open

func (m *Machine) Call(name string, args ...interface{}) (out interface{}, err error) {
    m.mu.Lock()
    defer m.mu.Unlock()

    defer func() {
Severity: Major
Found in call.go - About 45 mins to fix

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

    func TypeConvert(data interface{}) interface{} {
        switch v := data.(type) {
        case string:
            // Attempt parsing in different formats
            for _, format := range []string{time.RFC3339, time.RFC3339Nano, time.RFC822, time.RFC1123} {
    Severity: Major
    Found in dataconv/helper.go - About 45 mins to fix

      Method Machine.runInternal has 6 return statements (exceeds 4 allowed).
      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: Major
      Found in run.go - About 40 mins to fix

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

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

              case starlark.Tuple:
                  var (
                      i        int
                      tupleVal starlark.Value
                      iter     = v.Iterate()
          Severity: Minor
          Found in dataconv/marshal.go and 1 other location - About 40 mins to fix
          dataconv/marshal.go on lines 263..279

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

          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

              case *starlark.Set:
                  var (
                      i      int
                      setVal starlark.Value
                      iter   = v.Iterate()
          Severity: Minor
          Found in dataconv/marshal.go and 1 other location - About 40 mins to fix
          dataconv/marshal.go on lines 246..262

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

          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 goPingWrap has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func goPingWrap(ctx context.Context, address string, count int, timeout, interval time.Duration, pingFunc func(ctx context.Context, address string, timeout time.Duration) (time.Duration, error)) ([]time.Duration, error) {
          Severity: Minor
          Found in lib/net/ping.go - About 35 mins to fix

            Function setBody has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func setBody(req *http.Request, body *types.NullableStringOrBytes, formData *starlark.Dict, formEncoding starlark.String, jsonData starlark.Value) error {
            Severity: Minor
            Found in lib/http/http.go - About 35 mins to fix

              Function extractIOBottomLines has 5 return statements (exceeds 4 allowed).
              Open

              func extractIOBottomLines(rd io.Reader, n int) ([]string, error) {
                  if n <= 0 {
                      return nil, errors.New("n should be greater than 0")
                  }
                  var (
              Severity: Major
              Found in lib/file/line.go - About 35 mins to fix

                Method SharedDict.LoadJSON has 5 return statements (exceeds 4 allowed).
                Open

                func (s *SharedDict) LoadJSON(jsonStr string) error {
                    // check the dict itself
                    if s == nil {
                        return fmt.Errorf("nil shared dict")
                    }
                Severity: Major
                Found in dataconv/share.go - About 35 mins to fix

                  Function starTCPPing has 5 return statements (exceeds 4 allowed).
                  Open

                  func starTCPPing(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
                      var (
                          hostname tps.StringOrBytes
                          port                    = 80
                          count                   = 4
                  Severity: Major
                  Found in lib/net/ping.go - About 35 mins to fix

                    Function setAuth has 5 return statements (exceeds 4 allowed).
                    Open

                    func setAuth(req *http.Request, auth starlark.Tuple) error {
                        if len(auth) == 0 {
                            return nil
                        } else if len(auth) == 2 {
                            username, err := AsString(auth[0])
                    Severity: Major
                    Found in lib/http/http.go - About 35 mins to fix

                      Function httpPingFunc has 5 return statements (exceeds 4 allowed).
                      Open

                      func httpPingFunc(ctx context.Context, url string, timeout time.Duration) (time.Duration, error) {
                          // create a custom http client tracing
                          var (
                              onceStart, onceDone sync.Once
                              connStart           time.Time
                      Severity: Major
                      Found in lib/net/ping.go - About 35 mins to fix

                        Function readJSONL has 5 return statements (exceeds 4 allowed).
                        Open

                        func readJSONL(name string) (starlark.Value, error) {
                            var (
                                cnt    int
                                values []starlark.Value
                            )
                        Severity: Major
                        Found in lib/file/json.go - About 35 mins to fix

                          Function extractIOTopLines has 5 return statements (exceeds 4 allowed).
                          Open

                          func extractIOTopLines(rd io.Reader, n int) ([]string, error) {
                              if n <= 0 {
                                  return nil, errors.New("n should be greater than 0")
                              }
                              result := make([]string, 0)
                          Severity: Major
                          Found in lib/file/line.go - About 35 mins to fix

                            Function setHeaders has 5 return statements (exceeds 4 allowed).
                            Open

                            func setHeaders(req *http.Request, headers *starlark.Dict) error {
                                var (
                                    keys    = headers.Keys()
                                    UAKey   = "User-Agent"
                                    isUASet = false
                            Severity: Major
                            Found in lib/http/http.go - About 35 mins to fix

                              Method cache.doLoad has 5 return statements (exceeds 4 allowed).
                              Open

                              func (c *cache) doLoad(cc *cycleChecker, module string) (starlark.StringDict, error) {
                                  thread := &starlark.Thread{
                                      Print: func(_ *starlark.Thread, msg string) { fmt.Println(msg) },
                                      Load: func(_ *starlark.Thread, module string) (starlark.StringDict, error) {
                                          // Tunnel the cycle-checker state for this "thread of loading".
                              Severity: Major
                              Found in cache.go - About 35 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language