gitlabhq/gitlab-shell

View on GitHub

Showing 59 of 80 total issues

Function initialize has 58 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func initialize(t *testing.T) []testserver.TestRequestHandler {
    handler := func(w http.ResponseWriter, r *http.Request) {
        b, err := io.ReadAll(r.Body)
        defer r.Body.Close()

Severity: Minor
Found in internal/gitlabnet/twofactorverify/client_test.go - About 1 hr to fix

    Function initialize has 58 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func initialize(t *testing.T) {
        requests = []testserver.TestRequestHandler{
            {
                Path: "/api/v4/internal/personal_access_token",
                Handler: func(w http.ResponseWriter, r *http.Request) {
    Severity: Minor
    Found in internal/gitlabnet/personalaccesstoken/client_test.go - About 1 hr to fix

      Method mock_server has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def mock_server(server)
          server.mount_proc('/api/v4/internal/lfs_authenticate') do |req, res|
            res.content_type = 'application/json'
      
            key_id = req.query['key_id'] || req.query['user_id']
      Severity: Minor
      Found in spec/gitlab_shell_lfs_authentication_spec.rb - About 1 hr to fix

        Function buildRequests has 55 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func buildRequests(t *testing.T, relativeURLRoot string) []testserver.TestRequestHandler {
            requests := []testserver.TestRequestHandler{
                {
                    Path: "/api/v4/internal/hello",
                    Handler: func(w http.ResponseWriter, r *http.Request) {
        Severity: Minor
        Found in client/client_test.go - About 1 hr to fix

          Method mock_server has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def mock_server(server)
              server.mount_proc('/api/v4/internal/two_factor_manual_otp_check') do |req, res|
                res.content_type = 'application/json'
                res.status = 200
          
          
          Severity: Minor
          Found in spec/gitlab_shell_two_factor_verify_spec.rb - About 1 hr to fix

            Method session.handleShell has 55 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (s *session) handleShell(ctx context.Context, req *ssh.Request) (context.Context, uint32, error) {
                ctxlog := log.ContextLogger(ctx)
            
                if req.WantReply {
                    if err := req.Reply(true, []byte{}); err != nil {
            Severity: Minor
            Found in internal/sshd/session.go - About 1 hr to fix

              Function initialize has 54 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func initialize(t *testing.T) {
                  requests = []testserver.TestRequestHandler{
                      {
                          Path: "/api/v4/internal/two_factor_recovery_codes",
                          Handler: func(w http.ResponseWriter, r *http.Request) {
              Severity: Minor
              Found in internal/gitlabnet/twofactorrecover/client_test.go - About 1 hr to fix

                Function TestLfsTransferBatchDownload has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func TestLfsTransferBatchDownload(t *testing.T) {
                    url, cmd, pl, _ := setup(t, "rw", "group/repo", "download")
                    wg := setupWaitGroupForExecute(t, cmd)
                    negotiateVersion(t, pl)
                
                
                Severity: Minor
                Found in internal/command/lfstransfer/lfstransfer_test.go - About 1 hr to fix

                  Function TestHandleExec has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func TestHandleExec(t *testing.T) {
                      testCases := []struct {
                          desc               string
                          payload            []byte
                          expectedErr        error
                  Severity: Minor
                  Found in internal/sshd/session_test.go - About 1 hr to fix

                    Function main has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func main() {
                        command.CheckForVersionFlag(os.Args, Version, BuildTime)
                    
                        flag.Parse()
                    
                    
                    Severity: Minor
                    Found in cmd/gitlab-sshd/main.go - About 1 hr to fix

                      Method serverConfig.get has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                      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: Minor
                      Found in internal/sshd/server_config.go - About 1 hr to fix

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

                          def mock_server(server)
                            server.mount_proc('/api/v4/internal/two_factor_recovery_codes') do |req, res|
                              res.content_type = 'application/json'
                              res.status = 200
                        
                        
                        Severity: Minor
                        Found in spec/gitlab_shell_two_factor_recovery_spec.rb - About 1 hr 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 setup has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func setup(t *testing.T) []testserver.TestRequestHandler {
                            waitInfinitely := make(chan struct{})
                            requests := []testserver.TestRequestHandler{
                                {
                                    Path: "/api/v4/internal/two_factor_manual_otp_check",
                        Severity: Minor
                        Found in internal/command/twofactorverify/twofactorverify_test.go - About 1 hr to fix

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

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

                                  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 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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language