memnix/memnix-rest

View on GitHub

Showing 200 of 200 total issues

Function onEvent has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    onEvent: function(name, event) {

        // Only take actions on "htmx:afterProcessNode"
        if (name !== "htmx:afterProcessNode") {
            return;
Severity: Major
Found in assets/js/preload.js - About 3 hrs to fix

    Function onEvent has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        onEvent: function(name, event) {
    
            // Only take actions on "htmx:afterProcessNode"
            if (name !== "htmx:afterProcessNode") {
                return;
    Severity: Minor
    Found in assets/js/preload.js - About 2 hrs 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

    Function init has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            var init = function(node) {
    
                // If this node DOES NOT include a "GET" transaction, then there's nothing to do here.
                if (node.getAttribute("href") + node.getAttribute("hx-get") + node.getAttribute("data-hx-get") == "") {
                    return;
    Severity: Minor
    Found in assets/js/preload.js - About 1 hr to fix

      Function load has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              var load = function(node) {
      
                  // Called after a successful AJAX request, to mark the
                  // content as loaded (and prevent additional AJAX calls.)
                  var done = function(html) {
      Severity: Minor
      Found in assets/js/preload.js - About 1 hr to fix

        Function GetDiscordAccessToken has 6 return statements (exceeds 4 allowed).
        Open

        func GetDiscordAccessToken(ctx context.Context, code string) (string, error) {
            reqBody := bytes.NewBufferString(fmt.Sprintf(
                "client_id=%s&client_secret=%s&grant_type=authorization_code&redirect_uri=%s&code=%s&scope=identify,email",
                discordConfig.ClientID,
                discordConfig.ClientSecret,
        Severity: Major
        Found in pkg/oauth/discord.go - About 40 mins to fix

          Method Instance.GetConnectedUserID has 6 return statements (exceeds 4 allowed).
          Open

          func (instance Instance) GetConnectedUserID(ctx context.Context, tokenHeader string) (int32, error) {
              if tokenHeader == "" {
                  return 0, errors.New("empty token")
              }
          
          
          Severity: Major
          Found in pkg/jwt/jwt.go - About 40 mins to fix

            Method UseCase.Login has 5 return statements (exceeds 4 allowed).
            Open

            func (a *UseCase) Login(ctx context.Context, password string, email string) (string, error) {
                userModel, err := a.IRepository.GetByEmail(ctx, email)
                if err != nil {
                    slog.Error("user not found ", slog.Any("error", err), slog.String(" email", email))
                    return "", errors.New("user not found")
            Severity: Major
            Found in services/auth/usecase.go - About 35 mins to fix

              Method UseCase.Register has 5 return statements (exceeds 4 allowed).
              Open

              func (a *UseCase) Register(ctx context.Context, registerStruct domain.Register) (db.User, error) {
                  if err := VerifyPassword(registerStruct.Password); err != nil {
                      return db.User{}, errors.Wrap(err, "Verify password failed")
                  }
              
              
              Severity: Major
              Found in services/auth/usecase.go - About 35 mins to fix

                exported type PageController should have comment or be unexported
                Open

                type PageController struct{}
                Severity: Minor
                Found in app/v2/handlers/pages.go by golint

                exported type KeyManager should have comment or be unexported
                Open

                type KeyManager struct {
                Severity: Minor
                Found in pkg/crypto/keys.go by golint

                exported type IRepository should have comment or be unexported
                Open

                type IRepository interface {
                Severity: Minor
                Found in services/card/card.go by golint

                exported function NewRedisRepository should have comment or be unexported
                Open

                func NewRedisRepository(redisConn *redis.Client) IRedisRepository {
                Severity: Minor
                Found in services/mcq/redisRepository.go by golint

                exported function CSPMiddleware should have comment or be unexported
                Open

                func CSPMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
                Severity: Minor
                Found in app/v2/app.go by golint

                exported function GetCallbackURL should have comment or be unexported
                Open

                func GetCallbackURL() string {
                Severity: Minor
                Found in cmd/v2/config/config.go by golint

                exported function StaticAssetsCacheControlMiddleware should have comment or be unexported
                Open

                func StaticAssetsCacheControlMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
                Severity: Minor
                Found in app/v2/app.go by golint

                exported method PgxConnSingleton.WithConfig should have comment or be unexported
                Open

                func (p *PgxConnSingleton) WithConfig(config PgxConfig) *PgxConnSingleton {
                Severity: Minor
                Found in infrastructures/pgx.go by golint

                exported method PgxConnSingleton.GetPgxConn should have comment or be unexported
                Open

                func (p *PgxConnSingleton) GetPgxConn() *pgxpool.Pool {
                Severity: Minor
                Found in infrastructures/pgx.go by golint

                exported function Render should have comment or be unexported
                Open

                func Render(c echo.Context, _ int, t templ.Component) error {
                Severity: Minor
                Found in app/v2/handlers/utils.go by golint

                exported method RedisManager.ConnectRedis should have comment or be unexported
                Open

                func (r *RedisManager) ConnectRedis() error {
                Severity: Minor
                Found in infrastructures/redis.go by golint

                exported method JwtMiddleware.AuthorizeAdmin should have comment or be unexported
                Open

                func (j *JwtMiddleware) AuthorizeAdmin(next echo.HandlerFunc) echo.HandlerFunc {
                Severity: Minor
                Found in app/v2/security.go by golint
                Severity
                Category
                Status
                Source
                Language