Showing 15 of 15 total issues
Session
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Session struct {
cookie *http.Cookie
selectorID string
sessionID string
encryptedUsername string
Method HTTPAuth.signUp
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (a *HTTPAuth) signUp(w http.ResponseWriter, r *http.Request) {
// If the user is authenticated already, then we just redirect
if a.userIsAuthenticated(w, r) {
log.Printf("User requesting sign up page, but is already logged in. Redirecting to %v\n", a.RedirectAfterLogin)
return
Function SendMailSSL
has 9 return statements (exceeds 4 allowed). Open
Open
func SendMailSSL(addr string, auth smtp.Auth, username string, recpts []string, message []byte) error {
// TLS config
host, _, _ := net.SplitHostPort(addr)
tlsconfig := &tls.Config{
InsecureSkipVerify: false,
Function DefaultHTTPAuth
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func DefaultHTTPAuth(db *sql.DB, usersTableName, domainName string, allowXForwardedProto bool, emailSender *email.Sender, sessionTimeout, persistentSessionTimeout, csrfsTimeout, passwordResetTimeout time.Duration, cost int, secret []byte) (*HTTPAuth, error) {
Method HTTPAuth.signUp
has 7 return statements (exceeds 4 allowed). Open
Open
func (a *HTTPAuth) signUp(w http.ResponseWriter, r *http.Request) {
// If the user is authenticated already, then we just redirect
if a.userIsAuthenticated(w, r) {
log.Printf("User requesting sign up page, but is already logged in. Redirecting to %v\n", a.RedirectAfterLogin)
return
Function DefaultHTTPAuth
has 6 return statements (exceeds 4 allowed). Open
Open
func DefaultHTTPAuth(db *sql.DB, usersTableName, domainName string, allowXForwardedProto bool, emailSender *email.Sender, sessionTimeout, persistentSessionTimeout, csrfsTimeout, passwordResetTimeout time.Duration, cost int, secret []byte) (*HTTPAuth, error) {
var err error
g := func(pass []byte) ([]byte, error) {
return bcrypt.GenerateFromPassword(pass, cost)
}
Function NewHandlerWithDB
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewHandlerWithDB(db *sql.DB, tableName, cookieName string, sessionTimeout time.Duration, persistentSessionTimeout time.Duration, secret []byte) (*Handler, error) {
Function SendMailSSL
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func SendMailSSL(addr string, auth smtp.Auth, username string, recpts []string, message []byte) error {
Method HTTPAuth.PasswordResetAdapter
has 5 return statements (exceeds 4 allowed). Open
Open
func (a *HTTPAuth) PasswordResetAdapter() adaptd.Adapter {
// A check function that returns err == nil if the user is logged in or the password reset token is valid.
f := func(w http.ResponseWriter, r *http.Request) error {
username, err := a.passResetHandler.ValidToken(r)
tx := session.TxFromContext(r.Context())
Function PutTxOnContext
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func PutTxOnContext(db *sql.DB) adaptd.Adapter {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
tx, err := db.Begin()
if err != nil || tx == nil {
- 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
2: cannot find package "github.com/dadamssolutions/adaptd" in any of: Open
Open
"github.com/dadamssolutions/adaptd"
- Exclude checks
Your code does not pass gofmt in 1 place. Go fmt your code! Open
Open
/*Package smtpauth provides implementations of the smtp.Auth interface for sending messages
- Exclude checks
Your code does not pass gofmt in 1 place. Go fmt your code! Open
Open
/*
- Exclude checks
Your code does not pass gofmt in 1 place. Go fmt your code! Open
Open
/*Package csrf provides a functionality for creating, destroying, validating, and attaching
- Exclude checks
Your code does not pass gofmt in 1 place. Go fmt your code! Open
Open
/*Package passreset provies a handler for password reset token generation, validation, and deletion.
- Exclude checks