dorianim/formrecevr

View on GitHub

Showing 4 of 4 total issues

Function PostForm has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring.
Open

func PostForm(router *gin.RouterGroup) {
    router.POST("/:formID", func(c *gin.Context) {
        c.Header("Access-Control-Allow-Origin", "*")

        formConfig := getForm(c.Param("formID"))
Severity: Minor
Found in internal/api/form.go - About 4 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 PostForm has 81 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func PostForm(router *gin.RouterGroup) {
    router.POST("/:formID", func(c *gin.Context) {
        c.Header("Access-Control-Allow-Origin", "*")

        formConfig := getForm(c.Param("formID"))
Severity: Major
Found in internal/api/form.go - About 2 hrs to fix

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

    func PostForm(router *gin.RouterGroup) {
        router.POST("/:formID", func(c *gin.Context) {
            c.Header("Access-Control-Allow-Origin", "*")
    
            formConfig := getForm(c.Param("formID"))
    Severity: Major
    Found in internal/api/form.go - About 40 mins to fix

      Function ValidateTurnstileToken has 5 return statements (exceeds 4 allowed).
      Open

      func ValidateTurnstileToken(token string, secret string, remoteIp string) (bool, error) {
          req := TokenValidateRequest{
              Secret:   secret,
              Response: token,
              RemoteIP: remoteIp,
      Severity: Major
      Found in internal/api/turnstile.go - About 35 mins to fix
        Severity
        Category
        Status
        Source
        Language