gitlabhq/gitlab-shell

View on GitHub

Showing 71 of 107 total issues

Function TestUploadArchive has 51 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func TestUploadArchive(t *testing.T) {
    for _, network := range []string{"unix", "tcp", "dns"} {
        t.Run(fmt.Sprintf("via %s network", network), func(t *testing.T) {
            gitalyAddress, testServer := testserver.StartGitalyServer(t, network)
            t.Log(fmt.Sprintf("Server address: %s", gitalyAddress))
Severity: Minor
Found in internal/command/uploadarchive/gitalycall_test.go - About 1 hr to fix

    Function TestExecuteNoEOFSent has 51 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestExecuteNoEOFSent(t *testing.T) {
        who := "key-1"
    
        requests := []testserver.TestRequestHandler{
            {
    Severity: Minor
    Found in internal/command/shared/customaction/customaction_test.go - About 1 hr to fix

      Function TestScanner has 51 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TestScanner(t *testing.T) {
          largestPacket := "ffff" + largestString
          testCases := []struct {
              desc string
              in   string
      Severity: Minor
      Found in internal/pktline/pktline_test.go - About 1 hr to fix

        Function TestExecuteEOFSent has 51 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func TestExecuteEOFSent(t *testing.T) {
            who := "key-1"
        
            requests := []testserver.TestRequestHandler{
                {
        Severity: Minor
        Found in internal/command/shared/customaction/customaction_test.go - About 1 hr to fix

          Method mock_server has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def mock_server(server)
              server.mount_proc('/geo/proxy_git_ssh/info_refs_upload_pack') do |req, res|
                res.content_type = 'application/json'
                res.status = 200
          
          
          Severity: Minor
          Found in spec/gitlab_shell_custom_git_upload_pack_spec.rb - About 55 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 mock_server has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def mock_server(server)
              server.mount_proc('/geo/proxy_git_ssh/info_refs_receive_pack') do |req, res|
                res.content_type = 'application/json'
                res.status = 200
          
          
          Severity: Minor
          Found in spec/gitlab_shell_custom_git_receive_pack_spec.rb - About 55 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 GitlabBackend.parseAndCheckBatchArgs has 9 return statements (exceeds 4 allowed).
          Open

          func (b *GitlabBackend) parseAndCheckBatchArgs(op, oid, id, token string) (href string, headers map[string]string, err error) {
              if id == "" {
                  return "", nil, &errCustom{
                      err:     transfer.ErrParseError,
                      message: "missing id",
          Severity: Major
          Found in internal/command/lfstransfer/gitlab_backend.go - About 55 mins to fix

            Function pktLineSplitter has 8 return statements (exceeds 4 allowed).
            Open

            func pktLineSplitter(data []byte, atEOF bool) (advance int, token []byte, err error) {
                if len(data) < 4 {
                    if atEOF && len(data) > 0 {
                        return 0, nil, fmt.Errorf("pktLineSplitter: incomplete length prefix on %q", data)
                    }
            Severity: Major
            Found in internal/pktline/pktline.go - About 50 mins to fix

              Method Client.Lock has 7 return statements (exceeds 4 allowed).
              Open

              func (c *Client) Lock(path, refname string) (*Lock, error) {
                  var ref *batchRef
                  if refname != "" {
                      ref = &batchRef{
                          Name: refname,
              Severity: Major
              Found in internal/gitlabnet/lfstransfer/client.go - About 45 mins to fix

                Method mock_server has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def mock_server(server)
                    server.mount_proc('/api/v4/internal/discover') do |req, res|
                      identifier = req.query['key_id'] || req.query['username'] || req.query['user_id']
                      known_identifiers = %w(10 someuser 100)
                      if known_identifiers.include?(identifier)
                Severity: Minor
                Found in spec/gitlab_shell_discover_spec.rb - 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 Command.Execute has 6 return statements (exceeds 4 allowed).
                Open

                func (c *Command) Execute(ctx context.Context) (context.Context, error) {
                    args := c.Args.SshArgs
                    if len(args) != 2 {
                        return ctx, disallowedcommand.Error
                    }
                Severity: Major
                Found in internal/command/uploadpack/uploadpack.go - About 40 mins to fix

                  Method Command.Execute has 6 return statements (exceeds 4 allowed).
                  Open

                  func (c *Command) Execute(ctx context.Context) (context.Context, error) {
                      args := c.Args.SshArgs
                      if len(args) != 2 {
                          return ctx, disallowedcommand.Error
                      }
                  Severity: Major
                  Found in internal/command/receivepack/receivepack.go - About 40 mins to fix

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

                    func Audit(ctx context.Context, commandType commandargs.CommandType, c *config.Config, response *accessverifier.Response, packfileStats *pb.PackfileNegotiationStatistics) {
                    Severity: Minor
                    Found in internal/command/gitauditevent/audit.go - About 35 mins to fix

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

                      func writeCommandArgsAndTextData(t *testing.T, pl *pktline.Pktline, command string, args []string, data []string) {
                      Severity: Minor
                      Found in internal/command/lfstransfer/lfstransfer_test.go - About 35 mins to fix

                        Method Client.GetPersonalAccessToken has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        func (c *Client) GetPersonalAccessToken(ctx context.Context, args *commandargs.Shell, name string, scopes *[]string, expiresAt string) (*Response, error) {
                        Severity: Minor
                        Found in internal/gitlabnet/personalaccesstoken/client.go - About 35 mins to fix

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

                          func writeCommandArgsAndBinaryData(t *testing.T, pl *pktline.Pktline, command string, args []string, data [][]byte) {
                          Severity: Minor
                          Found in internal/command/lfstransfer/lfstransfer_test.go - About 35 mins to fix

                            Method Client.getRequestBody has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            func (c *Client) getRequestBody(ctx context.Context, args *commandargs.Shell, name string, scopes *[]string, expiresAt string) (*RequestBody, error) {
                            Severity: Minor
                            Found in internal/gitlabnet/personalaccesstoken/client.go - About 35 mins to fix

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

                              func listLocks(cursor string, limit int, refspec string, id string, path string) (locks []*LockInfo, nextCursor string) {
                              Severity: Minor
                              Found in internal/command/lfstransfer/lfstransfer_test.go - About 35 mins to fix

                                Method Client.Audit has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                func (c *Client) Audit(ctx context.Context, username string, action commandargs.CommandType, repo string, packfileStats *pb.PackfileNegotiationStatistics) error {
                                Severity: Minor
                                Found in internal/gitlabnet/gitauditevent/client.go - About 35 mins to fix

                                  Method Client.Batch has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (c *Client) Batch(operation string, reqObjects []*BatchObject, ref string, reqHashAlgo string) (*BatchResponse, error) {
                                      // FIXME: This causes tests to fail
                                      // if ref == "" {
                                      //     return nil, errors.New("A ref must be specified.")
                                      // }
                                  Severity: Major
                                  Found in internal/gitlabnet/lfstransfer/client.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language