gitlabhq/gitlab-shell

View on GitHub

Showing 71 of 107 total issues

Function TestUserKeyHandling has 67 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func TestUserKeyHandling(t *testing.T) {
    testRoot := testhelper.PrepareTestRootDir(t)

    validRSAKey := rsaPublicKey(t)

Severity: Minor
Found in internal/sshd/server_config_test.go - About 1 hr to fix

    Method mock_server has a Cognitive Complexity of 13 (exceeds 5 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

    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 39 lines of code (exceeds 25 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 1 hr to fix

      Function setup has 64 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

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

        Method mock_server has 39 lines of code (exceeds 25 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 1 hr to fix

          Function TestPrepareContext has 60 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func TestPrepareContext(t *testing.T) {
              tests := []struct {
                  name     string
                  gc       *GitalyCommand
                  env      sshenv.Env
          Severity: Minor
          Found in internal/handler/exec_test.go - About 1 hr to fix

            Function listLocks has 59 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func listLocks(cursor string, limit int, refspec string, id string, path string) (locks []*LockInfo, nextCursor string) {
                allLocks := []struct {
                    Refspec string
                    *LockInfo
                }{
            Severity: Minor
            Found in internal/command/lfstransfer/lfstransfer_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

                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

                  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 GitlabBackend.parseAndCheckBatchArgs has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                        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: Minor
                        Found in internal/command/lfstransfer/gitlab_backend.go - About 1 hr to fix

                          Function TestHandleExec has 55 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

                              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 TestLfsTransferBatchUpload has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                                  Open

                                  func TestLfsTransferBatchUpload(t *testing.T) {
                                      url, cmd, pl, _ := setup(t, "rw", "group/repo", "upload")
                                      wg := setupWaitGroupForExecute(t, cmd)
                                      negotiateVersion(t, pl)
                                  
                                  
                                  Severity: Minor
                                  Found in internal/command/lfstransfer/lfstransfer_test.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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language