gitlabhq/gitlab-shell

View on GitHub

Showing 80 of 80 total issues

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

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

    Avoid deeply nested control flow statements.
    Open

                    } else if r.URL.Query().Get("username") == "broken_json" {
                        w.Write([]byte("{ \"message\": \"broken json!\""))
                    } else if r.URL.Query().Get("username") == "broken_empty" {
                        w.WriteHeader(http.StatusForbidden)
                    } else {
    Severity: Major
    Found in internal/gitlabnet/discover/client_test.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 Client.Batch has 6 return statements (exceeds 4 allowed).
      Open

      func (c *Client) Batch(operation string, reqObjects []*BatchObject, ref string, reqHashAlgo string) (*BatchResponse, error) {
          var bref *batchRef
      
          // FIXME: This causes tests to fail
          // if ref == "" {
      Severity: Major
      Found in internal/gitlabnet/lfstransfer/client.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/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 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

              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

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

                      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

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

                        func newFromFile(path string) (*Config, error) {
                            cfg := &Config{}
                            *cfg = DefaultConfig
                            cfg.RootDir = filepath.Dir(path)
                        
                        
                        Severity: Major
                        Found in internal/config/config.go - About 35 mins to fix

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

                          func (c *Client) do(request *http.Request) (*http.Response, error) {
                              for k, v := range c.Headers {
                                  request.Header.Add(k, v)
                              }
                          
                          
                          Severity: Major
                          Found in internal/gitlabnet/git/client.go - About 35 mins to fix

                            Method Command.processAPIEndpoints has 5 return statements (exceeds 4 allowed).
                            Open

                            func (c *Command) processAPIEndpoints(ctx context.Context, response *accessverifier.Response) error {
                                client, err := gitlabnet.GetClient(c.Config)
                            
                                if err != nil {
                                    return err
                            Severity: Major
                            Found in internal/command/shared/customaction/customaction.go - About 35 mins to fix

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

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

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

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

                                  Method serverConfig.get has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (s *serverConfig) get(ctx context.Context) *ssh.ServerConfig {
                                      var gssapiWithMICConfig *ssh.GSSAPIWithMICConfig
                                      if s.cfg.Server.GSSAPI.Enabled {
                                          gssApiServer, _ := NewGSSAPIServer(&s.cfg.Server.GSSAPI)
                                  
                                  
                                  Severity: Major
                                  Found in internal/sshd/server_config.go - About 35 mins to fix

                                    Method OSGSSAPIServer.AcceptSecContext has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func (server *OSGSSAPIServer) AcceptSecContext(
                                        token []byte,
                                    ) (
                                        outputToken []byte,
                                        srcName string,
                                    Severity: Major
                                    Found in internal/sshd/gssapi.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language