mirror of
				https://github.com/MontFerret/ferret.git
				synced 2025-10-30 23:37:40 +02:00 
			
		
		
		
	Linter Cleanups (#294)
* sync with MontFerret/ferret * fix --param handling When params is converted to map it uses strings.Split, which slices a string into all substrings separated by :. * remove impossible conditions nil != nil * delete ineffectual assignments * replace '+= 1' with '++' * remove useless comparison with nil * merge variable declarations * remove bool comparison * fix imports * fix imports * delete unused file * use copy instead of loop * delete unused DummyInterface * remove unnecassary break statements * tidy modules
This commit is contained in:
		| @@ -50,6 +50,7 @@ func TestPush(t *testing.T) { | ||||
| 			values.True, | ||||
| 		) | ||||
|  | ||||
| 		So(err, ShouldBeNil) | ||||
| 		So(out2.String(), ShouldEqual, "[1,2,3,4,5,6]") | ||||
| 	}) | ||||
| } | ||||
|   | ||||
| @@ -52,11 +52,9 @@ func CookieDel(ctx context.Context, args ...core.Value) (core.Value, error) { | ||||
| 				cookies = append(cookies, found.(drivers.HTTPCookie)) | ||||
| 			} | ||||
|  | ||||
| 			break | ||||
| 		case drivers.HTTPCookie: | ||||
| 			cookies = append(cookies, cookie) | ||||
|  | ||||
| 			break | ||||
| 		default: | ||||
| 			return values.None, core.TypeError(c.Type(), types.String, drivers.HTTPCookieType) | ||||
| 		} | ||||
|   | ||||
| @@ -34,10 +34,6 @@ func CookieGet(ctx context.Context, args ...core.Value) (core.Value, error) { | ||||
| 	doc := args[0].(drivers.HTMLDocument) | ||||
| 	name := args[1].(values.String) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return values.None, err | ||||
| 	} | ||||
|  | ||||
| 	cookies, err := doc.GetCookies(ctx) | ||||
|  | ||||
| 	if err != nil { | ||||
|   | ||||
| @@ -155,11 +155,9 @@ func newDocLoadParams(url values.String, arg core.Value) (DocumentLoadParams, er | ||||
| 			res.Header = header | ||||
| 		} | ||||
|  | ||||
| 		break | ||||
| 	case types.String: | ||||
| 		res.Driver = arg.(values.String).String() | ||||
|  | ||||
| 		break | ||||
| 	case types.Boolean: | ||||
| 		b := arg.(values.Boolean) | ||||
|  | ||||
| @@ -168,7 +166,6 @@ func newDocLoadParams(url values.String, arg core.Value) (DocumentLoadParams, er | ||||
| 			res.Driver = cdp.DriverName | ||||
| 		} | ||||
|  | ||||
| 		break | ||||
| 	} | ||||
|  | ||||
| 	return res, nil | ||||
| @@ -196,9 +193,7 @@ func parseCookies(arr *values.Array) ([]drivers.HTTPCookie, error) { | ||||
| } | ||||
|  | ||||
| func parseCookie(value core.Value) (drivers.HTTPCookie, error) { | ||||
| 	var err error | ||||
|  | ||||
| 	err = core.ValidateType(value, types.Object, drivers.HTTPCookieType) | ||||
| 	err := core.ValidateType(value, types.Object, drivers.HTTPCookieType) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return drivers.HTTPCookie{}, err | ||||
| @@ -255,13 +250,10 @@ func parseCookie(value core.Value) (drivers.HTTPCookie, error) { | ||||
| 		switch sameSite { | ||||
| 		case "lax": | ||||
| 			cookie.SameSite = drivers.SameSiteLaxMode | ||||
| 			break | ||||
| 		case "strict": | ||||
| 			cookie.SameSite = drivers.SameSiteStrictMode | ||||
| 			break | ||||
| 		default: | ||||
| 			cookie.SameSite = drivers.SameSiteDefaultMode | ||||
| 			break | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -12,8 +12,7 @@ import ( | ||||
| // @param array (Array) - Array of numbers. | ||||
| // @returns (Float) - The average of the values in array. | ||||
| func Average(_ context.Context, args ...core.Value) (core.Value, error) { | ||||
| 	var err error | ||||
| 	err = core.ValidateArgs(args, 1, 1) | ||||
| 	err := core.ValidateArgs(args, 1, 1) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return values.None, err | ||||
|   | ||||
| @@ -12,8 +12,7 @@ import ( | ||||
| // @param array (Array) - Array of numbers. | ||||
| // @returns (Float) - The greatest of the values in array. | ||||
| func Max(_ context.Context, args ...core.Value) (core.Value, error) { | ||||
| 	var err error | ||||
| 	err = core.ValidateArgs(args, 1, 1) | ||||
| 	err := core.ValidateArgs(args, 1, 1) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return values.None, err | ||||
|   | ||||
| @@ -13,8 +13,7 @@ import ( | ||||
| // @param array (Array) - Array of numbers. | ||||
| // @returns (Float) - The median of the values in array. | ||||
| func Median(_ context.Context, args ...core.Value) (core.Value, error) { | ||||
| 	var err error | ||||
| 	err = core.ValidateArgs(args, 1, 1) | ||||
| 	err := core.ValidateArgs(args, 1, 1) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return values.None, err | ||||
|   | ||||
| @@ -12,8 +12,7 @@ import ( | ||||
| // @param array (Array) - Array of numbers. | ||||
| // @returns (Float) - The smallest of the values in array. | ||||
| func Min(_ context.Context, args ...core.Value) (core.Value, error) { | ||||
| 	var err error | ||||
| 	err = core.ValidateArgs(args, 1, 1) | ||||
| 	err := core.ValidateArgs(args, 1, 1) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return values.None, err | ||||
|   | ||||
| @@ -13,8 +13,7 @@ import ( | ||||
| // @params (Array) - Array of numbers. | ||||
| // @returns (Float) - The population standard deviation. | ||||
| func StandardDeviationPopulation(_ context.Context, args ...core.Value) (core.Value, error) { | ||||
| 	var err error | ||||
| 	err = core.ValidateArgs(args, 1, 1) | ||||
| 	err := core.ValidateArgs(args, 1, 1) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return values.None, err | ||||
|   | ||||
| @@ -13,8 +13,7 @@ import ( | ||||
| // @params (Array) - Array of numbers. | ||||
| // @returns (Float) - The sample standard deviation. | ||||
| func StandardDeviationSample(_ context.Context, args ...core.Value) (core.Value, error) { | ||||
| 	var err error | ||||
| 	err = core.ValidateArgs(args, 1, 1) | ||||
| 	err := core.ValidateArgs(args, 1, 1) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return values.None, err | ||||
|   | ||||
| @@ -12,8 +12,7 @@ import ( | ||||
| // @param array (Array) - Array of numbers. | ||||
| // @returns (Float) - The sum of the values. | ||||
| func Sum(_ context.Context, args ...core.Value) (core.Value, error) { | ||||
| 	var err error | ||||
| 	err = core.ValidateArgs(args, 1, 1) | ||||
| 	err := core.ValidateArgs(args, 1, 1) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return values.None, err | ||||
|   | ||||
| @@ -13,8 +13,7 @@ import ( | ||||
| // @params (Array) - Array of numbers. | ||||
| // @returns (Float) - The population variance. | ||||
| func PopulationVariance(_ context.Context, args ...core.Value) (core.Value, error) { | ||||
| 	var err error | ||||
| 	err = core.ValidateArgs(args, 1, 1) | ||||
| 	err := core.ValidateArgs(args, 1, 1) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return values.None, err | ||||
|   | ||||
| @@ -13,8 +13,7 @@ import ( | ||||
| // @params (Array) - Array of numbers. | ||||
| // @returns (Float) - The sample variance. | ||||
| func SampleVariance(_ context.Context, args ...core.Value) (core.Value, error) { | ||||
| 	var err error | ||||
| 	err = core.ValidateArgs(args, 1, 1) | ||||
| 	err := core.ValidateArgs(args, 1, 1) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return values.None, err | ||||
|   | ||||
| @@ -130,9 +130,7 @@ func TestFmt(t *testing.T) { | ||||
|  | ||||
| func (tc *testCase) Do(t *testing.T) { | ||||
| 	Convey(tc.Name, t, func() { | ||||
| 		var expected core.Value | ||||
|  | ||||
| 		expected = values.NewString(tc.Expected) | ||||
| 		var expected core.Value = values.NewString(tc.Expected) | ||||
|  | ||||
| 		args := []core.Value{values.NewString(tc.Format)} | ||||
| 		args = append(args, tc.Args...) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user