dadamssolutions/authentic

View on GitHub

Showing 15 of 15 total issues

Session has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

type Session struct {
    cookie            *http.Cookie
    selectorID        string
    sessionID         string
    encryptedUsername string
Severity: Minor
Found in handlers/session/sessions/session.go - About 2 hrs to fix

    Method HTTPAuth.signUp has 57 lines of code (exceeds 50 allowed). Consider refactoring.
    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
    Severity: Minor
    Found in signup.go - About 1 hr to fix

      Function SendMailSSL has 9 return statements (exceeds 4 allowed).
      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,
      Severity: Major
      Found in handlers/email/emailhandler.go - About 55 mins to fix

        Function DefaultHTTPAuth has 7 arguments (exceeds 4 allowed). Consider refactoring.
        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) {
        Severity: Major
        Found in auth.go - About 50 mins to fix

          Method HTTPAuth.signUp has 7 return statements (exceeds 4 allowed).
          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
          Severity: Major
          Found in signup.go - About 45 mins to fix

            Function DefaultHTTPAuth has 6 return statements (exceeds 4 allowed).
            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)
                }
            Severity: Major
            Found in auth.go - About 40 mins to fix

              Function NewHandlerWithDB has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func NewHandlerWithDB(db *sql.DB, tableName, cookieName string, sessionTimeout time.Duration, persistentSessionTimeout time.Duration, secret []byte) (*Handler, error) {
              Severity: Minor
              Found in handlers/session/seshandler.go - About 35 mins to fix

                Function SendMailSSL has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func SendMailSSL(addr string, auth smtp.Auth, username string, recpts []string, message []byte) error {
                Severity: Minor
                Found in handlers/email/emailhandler.go - About 35 mins to fix

                  Method HTTPAuth.PasswordResetAdapter has 5 return statements (exceeds 4 allowed).
                  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())
                  Severity: Major
                  Found in passwordreset.go - About 35 mins to fix

                    Function PutTxOnContext has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                    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 {
                    Severity: Minor
                    Found in adapters.go - About 25 mins 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

                    2: cannot find package "github.com/dadamssolutions/adaptd" in any of:
                    Open

                        "github.com/dadamssolutions/adaptd"
                    Severity: Minor
                    Found in adapters.go by govet

                    Your code does not pass gofmt in 1 place. Go fmt your code!
                    Open

                    /*Package smtpauth provides implementations of the smtp.Auth interface for sending messages
                    Severity: Minor
                    Found in handlers/email/smtpauth/smtpauth.go by gofmt

                    Your code does not pass gofmt in 1 place. Go fmt your code!
                    Open

                    /*
                    Severity: Minor
                    Found in handlers/session/seshandler.go by gofmt

                    Your code does not pass gofmt in 1 place. Go fmt your code!
                    Open

                    /*Package csrf provides a functionality for creating, destroying, validating, and attaching
                    Severity: Minor
                    Found in handlers/csrf/csrfhandler.go by gofmt

                    Your code does not pass gofmt in 1 place. Go fmt your code!
                    Open

                    /*Package passreset provies a handler for password reset token generation, validation, and deletion.
                    Severity: Minor
                    Found in handlers/passreset/passreset.go by gofmt
                    Severity
                    Category
                    Status
                    Source
                    Language