Showing 46 of 1,879 total issues
Function TestUnpackHandshakeV10
has 88 lines of code (exceeds 70 allowed). Consider refactoring. Open
func TestUnpackHandshakeV10(t *testing.T) {
type UnpackHandshakeV10Assert struct {
Packet []byte
HasError bool
Function UnpackHandshakeV10
has 87 lines of code (exceeds 70 allowed). Consider refactoring. Open
func UnpackHandshakeV10(packet []byte) (*HandshakeV10, error) {
r := bytes.NewReader(packet)
// Header
header, err := GetPacketHeader(r)
Method AuthenticationHandshake.handleBackendAuthResponse
has 87 lines of code (exceeds 70 allowed). Consider refactoring. Open
func (h *AuthenticationHandshake) handleBackendAuthResponse() {
if h.err != nil {
return
}
Method LogTest.RunAllTests
has 86 lines of code (exceeds 70 allowed). Consider refactoring. Open
func (lt *LogTest) RunAllTests(t *testing.T) {
// Format strings and sample arguments used in the test cases
const testCaseFormatStr = "aaa %s bbb %d ccc %2.1f ddd \t eee"
testCaseArgs := []interface{}{"stringval", 123, 1.234}
Method AuthenticationHandshake.handleBackendAuthResponse
has 17 return statements (exceeds 7 allowed). Open
func (h *AuthenticationHandshake) handleBackendAuthResponse() {
if h.err != nil {
return
}
Function extractShellCommand
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function extractShellCommand(shellBlock) {
var blockLines = shellBlock.innerText.split("\n");
var command = "";
var includeNextLine = true;
- 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 proxyService.Start
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func (proxy *proxyService) Start() error {
logger := proxy.logger
logger.Infof("Starting service")
- 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 main
has 74 lines of code (exceeds 70 allowed). Consider refactoring. Open
func main() {
log.Println("Secretless CRD watcher starting up...")
var kubeConfig *string
if home := getHomeDir(); home != "" {
Function UnpackHandshakeV10
has 14 return statements (exceeds 7 allowed). Open
func UnpackHandshakeV10(packet []byte) (*HandshakeV10, error) {
r := bytes.NewReader(packet)
// Header
header, err := GetPacketHeader(r)
Function handleAuthSCRAM
has 14 return statements (exceeds 7 allowed). Open
func handleAuthSCRAM(username string, password string, connection net.Conn) error {
sc := scram.NewClient(sha256.New, username, password)
sc.Step(nil)
if sc.Err() != nil {
return fmt.Errorf("SCRAM-SHA-256 error: %s", sc.Err().Error())
Function TestV1HttpHandlerConversion
has 72 lines of code (exceeds 70 allowed). Consider refactoring. Open
func TestV1HttpHandlerConversion(t *testing.T) {
t.Run("connectorConfig field maps correctly", func(t *testing.T) {
v1Cfg := v1HttpExample()
v2Cfg, err := NewV2Config(v1Cfg)
assert.NoError(t, err)
Function UnpackHandshakeResponse41
has 72 lines of code (exceeds 70 allowed). Consider refactoring. Open
func UnpackHandshakeResponse41(packet []byte) (*HandshakeResponse41, error) {
r := bytes.NewReader(packet)
// Skip packet header (but save in struct)
header, err := GetPacketHeader(r)
Function UnpackHandshakeV10
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func UnpackHandshakeV10(packet []byte) (*HandshakeV10, error) {
r := bytes.NewReader(packet)
// Header
header, err := GetPacketHeader(r)
- 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 UnpackHandshakeResponse41
has 11 return statements (exceeds 7 allowed). Open
func UnpackHandshakeResponse41(packet []byte) (*HandshakeResponse41, error) {
r := bytes.NewReader(packet)
// Skip packet header (but save in struct)
header, err := GetPacketHeader(r)
Function UnpackOkResponse
has 9 return statements (exceeds 7 allowed). Open
func UnpackOkResponse(packet []byte) (*OkResponse, error) {
// Min packet length = header(4 bytes) + PacketType(1 byte)
if err := CheckPacketLength(5, packet); err != nil {
return nil, err
Function InjectCredentials
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func InjectCredentials(authPlugin string, clientHandshake *HandshakeResponse41, salt []byte, username string, password string) (err error) {
Function AllAvailablePluginsWithOptions
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
pluginDir string,
checksumsFile string,
internalLookupFunc InternalPluginLookupFunc,
externalLookupfunc ExternalPluginLookupFunc,
logger log.Logger,
Function runTest
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func runTest(backendName string, threadIndex int, aggregateTimings *timing.AggregateTimings,
testManager *TestManager, round int) time.Duration {
Function RemoveSSLFromHandshakeV10
has 8 return statements (exceeds 7 allowed). Open
func RemoveSSLFromHandshakeV10(packet []byte) ([]byte, error) {
r := bytes.NewReader(packet)
initialLen := r.Len()
// Skip packet header
Function ProviderFactory
has 8 return statements (exceeds 7 allowed). Open
func ProviderFactory(options plugin_v1.ProviderOptions) (plugin_v1.Provider, error) {
config, err := conjurapi.LoadConfig()
if err != nil {
return nil, fmt.Errorf("ERROR: Conjur provider could not load configuration: %s", err)
}