1set/starlet

View on GitHub

Showing 51 of 84 total issues

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

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

                func convertToDict(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
                    var v starlark.Value
                    if err := starlark.UnpackArgs(b.Name(), args, kwargs, "v", &v); err != nil {
                        return nil, err
                    }
                Severity: Major
                Found in lib/goidiomatic/idiomatic.go - About 35 mins to fix

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

                  func sharedDictFromJSON(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
                      // check the arguments
                      var s tps.StringOrBytes
                      if err := starlark.UnpackArgs(b.Name(), args, kwargs, "x", &s); err != nil {
                          return nil, err
                  Severity: Major
                  Found in dataconv/share.go - About 35 mins to fix

                    Method Module.genLoggerBuiltin has a Cognitive Complexity of 22 (exceeds 20 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 35 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

                    Function processArgs has a Cognitive Complexity of 21 (exceeds 20 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 25 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

                    Severity
                    Category
                    Status
                    Source
                    Language