Showing 71 of 107 total issues
Function TestUserKeyHandling
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestUserKeyHandling(t *testing.T) {
testRoot := testhelper.PrepareTestRootDir(t)
validRSAKey := rsaPublicKey(t)
Method mock_server
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
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
- Read upRead up
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
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
Function setup
has 64 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func setup(t *testing.T) *Client {
requests := []testserver.TestRequestHandler{
{
Path: "/info/refs",
Handler: func(w http.ResponseWriter, r *http.Request) {
Method mock_server
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function TestPrepareContext
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestPrepareContext(t *testing.T) {
tests := []struct {
name string
gc *GitalyCommand
env sshenv.Env
Function listLocks
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func listLocks(cursor string, limit int, refspec string, id string, path string) (locks []*LockInfo, nextCursor string) {
allLocks := []struct {
Refspec string
*LockInfo
}{
Function initialize
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func initialize(t *testing.T) {
requests = []testserver.TestRequestHandler{
{
Path: "/api/v4/internal/personal_access_token",
Handler: func(w http.ResponseWriter, r *http.Request) {
Function initialize
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
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()
Method mock_server
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
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']
Function buildRequests
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
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) {
Method mock_server
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Method GitlabBackend.parseAndCheckBatchArgs
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
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",
Function TestHandleExec
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestHandleExec(t *testing.T) {
testCases := []struct {
desc string
payload []byte
expectedErr error
Function main
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func main() {
command.CheckForVersionFlag(os.Args, Version, BuildTime)
flag.Parse()
Function initialize
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
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) {
Function TestLfsTransferBatchDownload
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestLfsTransferBatchDownload(t *testing.T) {
url, cmd, pl, _ := setup(t, "rw", "group/repo", "download")
wg := setupWaitGroupForExecute(t, cmd)
negotiateVersion(t, pl)
Function TestLfsTransferBatchUpload
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestLfsTransferBatchUpload(t *testing.T) {
url, cmd, pl, _ := setup(t, "rw", "group/repo", "upload")
wg := setupWaitGroupForExecute(t, cmd)
negotiateVersion(t, pl)
Method mock_server
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
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
- Read upRead up
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
Open
func setup(t *testing.T) []testserver.TestRequestHandler {
waitInfinitely := make(chan struct{})
requests := []testserver.TestRequestHandler{
{
Path: "/api/v4/internal/two_factor_manual_otp_check",