reduce cyclomatic complexity for my GPA. Sucks.

This commit is contained in:
Ian A. Mason 2018-04-27 19:29:45 -07:00
parent 0c39531dd6
commit 114f1e8ed4

View File

@ -59,26 +59,64 @@ func getFileType(realPath string) (fileType int) {
LogFatal("There was an error getting the type of %s. Make sure that the 'file' command is installed.", realPath)
}
// Test the output
if fo := string(out); strings.Contains(fo, "ELF") && strings.Contains(fo, "executable") {
fileType = fileTypeELFEXECUTABLE
} else if strings.Contains(fo, "Mach-O") && strings.Contains(fo, "executable") {
fileType = fileTypeMACHEXECUTABLE
} else if strings.Contains(fo, "ELF") && strings.Contains(fo, "shared") {
fileType = fileTypeELFSHARED
} else if strings.Contains(fo, "Mach-O") && strings.Contains(fo, "dynamically linked shared") {
fileType = fileTypeMACHSHARED
fo := string(out)
if strings.Contains(fo, "ELF") {
if strings.Contains(fo, "executable") {
fileType = fileTypeELFEXECUTABLE
} else if strings.Contains(fo, "shared") {
fileType = fileTypeELFSHARED
} else if strings.Contains(fo, "relocatable") {
fileType = fileTypeELFOBJECT
} else {
fileType = fileTypeUNDEFINED
}
} else if strings.Contains(fo, "Mach-O") {
if strings.Contains(fo, "executable") {
fileType = fileTypeMACHEXECUTABLE
} else if strings.Contains(fo, "dynamically linked shared") {
fileType = fileTypeMACHSHARED
} else if strings.Contains(fo, "object") {
fileType = fileTypeMACHOBJECT
} else {
fileType = fileTypeUNDEFINED
}
} else if strings.Contains(fo, "current ar archive") {
fileType = fileTypeARCHIVE
} else if strings.Contains(fo, "thin archive") {
fileType = fileTypeTHINARCHIVE
} else if strings.Contains(fo, "ELF") && strings.Contains(fo, "relocatable") {
fileType = fileTypeELFOBJECT
} else if strings.Contains(fo, "Mach-O") && strings.Contains(fo, "object") {
fileType = fileTypeMACHOBJECT
} else {
} else {
fileType = fileTypeUNDEFINED
}
// Test the output
// if fo := string(out); strings.Contains(fo, "ELF") && strings.Contains(fo, "executable") {
// fileType = fileTypeELFEXECUTABLE
// } else if strings.Contains(fo, "Mach-O") && strings.Contains(fo, "executable") {
// fileType = fileTypeMACHEXECUTABLE
// } else if strings.Contains(fo, "ELF") && strings.Contains(fo, "shared") {
// fileType = fileTypeELFSHARED
// } else if strings.Contains(fo, "Mach-O") && strings.Contains(fo, "dynamically linked shared") {
// fileType = fileTypeMACHSHARED
// } else if strings.Contains(fo, "current ar archive") {
// fileType = fileTypeARCHIVE
// } else if strings.Contains(fo, "thin archive") {
// fileType = fileTypeTHINARCHIVE
// } else if strings.Contains(fo, "ELF") && strings.Contains(fo, "relocatable") {
// fileType = fileTypeELFOBJECT
// } else if strings.Contains(fo, "Mach-O") && strings.Contains(fo, "object") {
// fileType = fileTypeMACHOBJECT
// } else {
// fileType = fileTypeUNDEFINED
// }
return
}