Coder Social home page Coder Social logo

kit's People

Contributors

ehanken21 avatar paulwalker avatar shamne avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kit's Issues

TemplateWithConfig has pointless branch?

In web/middleware/template.go, we have the following function:

func TemplateWithConfig(config TemplateConfig) echo.MiddlewareFunc {
	if config.Skipper == nil {
		config.Skipper = DefaultTemplateConfig.Skipper
	}

	return func(next echo.HandlerFunc) echo.HandlerFunc {
		return func(c echo.Context) (err error) {
			if config.Skipper(c) { // this branch does nothing
				return next(c)
			}

			return next(c)
		}
	}
}

Specifically:

{
    if config.Skipper(c){
        return next(c)
    }
    return next(c)
}

seems wrong. Why do we test for config.Skipper if it doesn't matter? Does it have side effects? Couldn't we just replace the whole branch withreturn next(c)?

goto ERROR in web/error_handler.go

We have a GOTO in the following function in web/error_handler.go

goto ERROR is identical to

logErr(err)
return

here. Is this a relic of a former system, or for performance reasons?

func ErrorHandler(err error, c echo.Context) {
	if c.Response().Committed {
		return
	}

	status, apiError := toApiError(err)

	if c.Request().Method == "HEAD" {
		if err := c.NoContent(status); err != nil {
			goto ERROR
		}
		return
	}

	if err := renderApiErrors(c, apiError); err != nil {
		//are we supposed to log this error twice?
		logErr(err)
		goto ERROR
	}

	if status < 500 {
		return
	}
ERROR:
	logErr(err)
}

BeenSet default behavior

In cfg/cfg.go, we have the function BeenSet.

BeenSet generally shows whether or not the value of a type is the NOT zero value of a type (with the exception of bool).

However, the default case here shows whether the value of a type IS the zero value of interface{}.

This seems wrong!

func BeenSet(v interface{}) bool {
	switch v.(type) {
	case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64:
		return v.(int) != 0
	case string, []rune, []byte:
		return v.(string) != ""
	case []int, []int8, []int16, []int64, []uint, []uint16, []uint64, []float32, []float64:
		return v.([]interface{}) != nil
	case bool:
		return true // no way to tell
	default:
		var other interface{} 
		return v.(interface{}) == other
                //should this be !=??
       
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.