Browse Source

Add GDScript `.editorconfig` rules

- Uniformize `.gd` unit test files indentation to tabs (where needed)
Adam Scott 2 years ago
parent
commit
44d1d72af1
25 changed files with 236 additions and 226 deletions
  1. 10 0
      .editorconfig
  2. 1 0
      modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.gd
  3. 7 7
      modules/gdscript/tests/scripts/analyzer/errors/outer_class_lookup.gd
  4. 1 1
      modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd
  5. 3 3
      modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd
  6. 0 1
      modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.gd
  7. 10 10
      modules/gdscript/tests/scripts/analyzer/features/class_from_parent.gd
  8. 2 2
      modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.gd
  9. 2 2
      modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant_external.notest.gd
  10. 28 28
      modules/gdscript/tests/scripts/analyzer/features/lookup_class.gd
  11. 29 29
      modules/gdscript/tests/scripts/analyzer/features/lookup_signal.gd
  12. 2 2
      modules/gdscript/tests/scripts/analyzer/features/return_variant_typed.gd
  13. 1 1
      modules/gdscript/tests/scripts/parser/errors/class_name_after_annotation.gd
  14. 1 1
      modules/gdscript/tests/scripts/parser/errors/double_dictionary_comma.gd
  15. 3 3
      modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.gd
  16. 31 31
      modules/gdscript/tests/scripts/parser/features/advanced_expression_matching.gd
  17. 24 24
      modules/gdscript/tests/scripts/parser/features/basic_expression_matching.gd
  18. 3 3
      modules/gdscript/tests/scripts/parser/features/lambda_callable.gd
  19. 38 38
      modules/gdscript/tests/scripts/parser/features/match_dictionary.gd
  20. 20 20
      modules/gdscript/tests/scripts/parser/features/match_multiple_patterns_with_array.gd
  21. 5 5
      modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.gd
  22. 1 1
      modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.gd
  23. 1 1
      modules/gdscript/tests/scripts/runtime/features/array_string_stringname_equivalent.gd
  24. 1 1
      modules/gdscript/tests/scripts/runtime/features/dictionary_string_stringname_equivalent.gd
  25. 12 12
      modules/gdscript/tests/scripts/runtime/features/parameter_shadowing.gd

+ 10 - 0
.editorconfig

@@ -21,3 +21,13 @@ indent_size = 4
 [*.{yml,yaml}]
 indent_style = space
 indent_size = 2
+
+# GDScript unit test files
+[*.gd]
+indent_style = tab
+indent_size = 4
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.out]
+insert_final_newline = true

+ 1 - 0
modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.gd

@@ -1,4 +1,5 @@
 enum MyEnum { VALUE_A, VALUE_B, VALUE_C = 42 }
+
 func test():
 	const P = preload("../features/enum_value_from_parent.gd")
 	var local_var: MyEnum

+ 7 - 7
modules/gdscript/tests/scripts/analyzer/errors/outer_class_lookup.gd

@@ -1,12 +1,12 @@
 class A:
-    class B:
-        func test():
-            print(A.B.D)
+	class B:
+		func test():
+			print(A.B.D)
 
 class C:
-    class D:
-        pass
+	class D:
+		pass
 
 func test():
-    var inst = A.B.new()
-    inst.test()
+	var inst = A.B.new()
+	inst.test()

+ 1 - 1
modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd

@@ -1,2 +1,2 @@
 func test() -> void:
-  return null
+	return null

+ 3 - 3
modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd

@@ -1,4 +1,4 @@
 func test() -> void:
-  var a
-  a = 1
-  return a
+	var a
+	a = 1
+	return a

+ 0 - 1
modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.gd

@@ -11,4 +11,3 @@ func test() -> void:
 	Extend.InnerClass.InnerInnerClass.test_a_b_c(A.new(), B.new(), C.new())
 	Extend.InnerClass.InnerInnerClass.test_enum(C.TestEnum.HELLO_WORLD)
 	Extend.InnerClass.InnerInnerClass.test_a_prime(A.APrime.new())
-

+ 10 - 10
modules/gdscript/tests/scripts/analyzer/features/class_from_parent.gd

@@ -1,19 +1,19 @@
 class A:
-    var x = 3
+	var x = 3
 
 class B:
-    var x = 4
+	var x = 4
 
 class C:
-    var x = 5
+	var x = 5
 
 class Test:
-    var a = A.new()
-    var b: B = B.new()
-    var c := C.new()
+	var a = A.new()
+	var b: B = B.new()
+	var c := C.new()
 
 func test():
-    var test_instance := Test.new()
-    prints(test_instance.a.x)
-    prints(test_instance.b.x)
-    prints(test_instance.c.x)
+	var test_instance := Test.new()
+	prints(test_instance.a.x)
+	prints(test_instance.b.x)
+	prints(test_instance.c.x)

+ 2 - 2
modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.gd

@@ -2,5 +2,5 @@ const External = preload("external_enum_as_constant_external.notest.gd")
 const MyEnum = External.MyEnum
 
 func test():
-    print(MyEnum.WAITING == 0)
-    print(MyEnum.GODOT == 1)
+	print(MyEnum.WAITING == 0)
+	print(MyEnum.GODOT == 1)

+ 2 - 2
modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant_external.notest.gd

@@ -1,4 +1,4 @@
 enum MyEnum {
-    WAITING,
-    GODOT
+	WAITING,
+	GODOT
 }

+ 28 - 28
modules/gdscript/tests/scripts/analyzer/features/lookup_class.gd

@@ -1,50 +1,50 @@
 # Inner-outer class lookup
 class A:
-    const Q: = "right one"
+	const Q: = "right one"
 
 class X:
-    const Q: = "wrong one"
+	const Q: = "wrong one"
 
 class Y extends X:
-    class B extends A:
-        static func check() -> void:
-            print(Q)
+	class B extends A:
+		static func check() -> void:
+			print(Q)
 
 # External class lookup
 const External: = preload("lookup_class_external.notest.gd")
 
 class Internal extends External.A:
-    static func check() -> void:
-        print(TARGET)
+	static func check() -> void:
+		print(TARGET)
 
-    class E extends External.E:
-        static func check() -> void:
-            print(TARGET)
-            print(WAITING)
+	class E extends External.E:
+		static func check() -> void:
+			print(TARGET)
+			print(WAITING)
 
 # Variable lookup
 class C:
-    var Q := 'right one'
+	var Q := 'right one'
 
 class D:
-    const Q := 'wrong one'
+	const Q := 'wrong one'
 
 class E extends D:
-    class F extends C:
-        func check() -> void:
-            print(Q)
+	class F extends C:
+		func check() -> void:
+			print(Q)
 
 # Test
 func test() -> void:
-    # Inner-outer class lookup
-    Y.B.check()
-    print("---")
-
-    # External class lookup
-    Internal.check()
-    Internal.E.check()
-    print("---")
-
-    # Variable lookup
-    var f: = E.F.new()
-    f.check()
+	# Inner-outer class lookup
+	Y.B.check()
+	print("---")
+
+	# External class lookup
+	Internal.check()
+	Internal.E.check()
+	print("---")
+
+	# Variable lookup
+	var f: = E.F.new()
+	f.check()

+ 29 - 29
modules/gdscript/tests/scripts/analyzer/features/lookup_signal.gd

@@ -1,41 +1,41 @@
 signal hello
 
 func get_signal() -> Signal:
-    return hello
+	return hello
 
 class A:
-    signal hello
+	signal hello
 
-    func get_signal() -> Signal:
-        return hello
+	func get_signal() -> Signal:
+		return hello
 
-    class B:
-        signal hello
+	class B:
+		signal hello
 
-        func get_signal() -> Signal:
-            return hello
+		func get_signal() -> Signal:
+			return hello
 
 class C extends A.B:
-    func get_signal() -> Signal:
-        return hello
+	func get_signal() -> Signal:
+		return hello
 
 func test():
-    var a: = A.new()
-    var b: = A.B.new()
-    var c: = C.new()
-
-    var hello_a_result: = hello == a.get_signal()
-    var hello_b_result: = hello == b.get_signal()
-    var hello_c_result: = hello == c.get_signal()
-    var a_b_result: = a.get_signal() == b.get_signal()
-    var a_c_result: = a.get_signal() == c.get_signal()
-    var b_c_result: = b.get_signal() == c.get_signal()
-    var c_c_result: = c.get_signal() == c.get_signal()
-
-    print("hello == A.hello? %s" % hello_a_result)
-    print("hello == A.B.hello? %s" % hello_b_result)
-    print("hello == C.hello? %s" % hello_c_result)
-    print("A.hello == A.B.hello? %s" % a_b_result)
-    print("A.hello == C.hello? %s" % a_c_result)
-    print("A.B.hello == C.hello? %s" % b_c_result)
-    print("C.hello == C.hello? %s" % c_c_result)
+	var a: = A.new()
+	var b: = A.B.new()
+	var c: = C.new()
+
+	var hello_a_result: = hello == a.get_signal()
+	var hello_b_result: = hello == b.get_signal()
+	var hello_c_result: = hello == c.get_signal()
+	var a_b_result: = a.get_signal() == b.get_signal()
+	var a_c_result: = a.get_signal() == c.get_signal()
+	var b_c_result: = b.get_signal() == c.get_signal()
+	var c_c_result: = c.get_signal() == c.get_signal()
+
+	print("hello == A.hello? %s" % hello_a_result)
+	print("hello == A.B.hello? %s" % hello_b_result)
+	print("hello == C.hello? %s" % hello_c_result)
+	print("A.hello == A.B.hello? %s" % a_b_result)
+	print("A.hello == C.hello? %s" % a_c_result)
+	print("A.B.hello == C.hello? %s" % b_c_result)
+	print("C.hello == C.hello? %s" % c_c_result)

+ 2 - 2
modules/gdscript/tests/scripts/analyzer/features/return_variant_typed.gd

@@ -1,5 +1,5 @@
 func variant() -> Variant:
-  return 'variant'
+	return 'variant'
 
 func test():
-  print(variant())
+	print(variant())

+ 1 - 1
modules/gdscript/tests/scripts/parser/errors/class_name_after_annotation.gd

@@ -3,4 +3,4 @@
 class_name HelloWorld
 
 func test():
-    pass
+	pass

+ 1 - 1
modules/gdscript/tests/scripts/parser/errors/double_dictionary_comma.gd

@@ -1,2 +1,2 @@
 func test():
-    var dictionary = { hello = "world",, }
+	var dictionary = { hello = "world",, }

+ 3 - 3
modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.gd

@@ -1,4 +1,4 @@
 func test():
-    match 1:
-        [[[var a]]], 2:
-            pass
+	match 1:
+		[[[var a]]], 2:
+			pass

+ 31 - 31
modules/gdscript/tests/scripts/parser/features/advanced_expression_matching.gd

@@ -1,34 +1,34 @@
 func foo(x):
-    match x:
-        1 + 1:
-            print("1+1")
-        [1,2,[1,{1:2,2:var z,..}]]:
-            print("[1,2,[1,{1:2,2:var z,..}]]")
-            print(z)
-        1 if true else 2:
-            print("1 if true else 2")
-        1 < 2:
-            print("1 < 2")
-        1 or 2 and 1:
-            print("1 or 2 and 1")
-        6 | 1:
-            print("1 | 1")
-        1 >> 1:
-            print("1 >> 1")
-        1, 2 or 3, 4:
-            print("1, 2 or 3, 4")
-        _:
-            print("wildcard")
+	match x:
+		1 + 1:
+			print("1+1")
+		[1,2,[1,{1:2,2:var z,..}]]:
+			print("[1,2,[1,{1:2,2:var z,..}]]")
+			print(z)
+		1 if true else 2:
+			print("1 if true else 2")
+		1 < 2:
+			print("1 < 2")
+		1 or 2 and 1:
+			print("1 or 2 and 1")
+		6 | 1:
+			print("1 | 1")
+		1 >> 1:
+			print("1 >> 1")
+		1, 2 or 3, 4:
+			print("1, 2 or 3, 4")
+		_:
+			print("wildcard")
 
 func test():
-    foo(6 | 1)
-    foo(1 >> 1)
-    foo(2)
-    foo(1)
-    foo(1+1)
-    foo(1 < 2)
-    foo([2, 1])
-    foo(4)
-    foo([1, 2, [1, {1 : 2, 2:3}]])
-    foo([1, 2, [1, {1 : 2, 2:[1,3,5, "123"], 4:2}]])
-    foo([1, 2, [1, {1 : 2}]])
+	foo(6 | 1)
+	foo(1 >> 1)
+	foo(2)
+	foo(1)
+	foo(1+1)
+	foo(1 < 2)
+	foo([2, 1])
+	foo(4)
+	foo([1, 2, [1, {1 : 2, 2:3}]])
+	foo([1, 2, [1, {1 : 2, 2:[1,3,5, "123"], 4:2}]])
+	foo([1, 2, [1, {1 : 2}]])

+ 24 - 24
modules/gdscript/tests/scripts/parser/features/basic_expression_matching.gd

@@ -1,27 +1,27 @@
 func foo(x):
-    match x:
-        1:
-            print("1")
-        2:
-            print("2")
-        [1, 2]:
-            print("[1, 2]")
-        3 or 4:
-            print("3 or 4")
-        4:
-            print("4")
-        {1 : 2, 2 : 3}:
-            print("{1 : 2, 2 : 3}")
-        _:
-            print("wildcard")
+	match x:
+		1:
+			print("1")
+		2:
+			print("2")
+		[1, 2]:
+			print("[1, 2]")
+		3 or 4:
+			print("3 or 4")
+		4:
+			print("4")
+		{1 : 2, 2 : 3}:
+			print("{1 : 2, 2 : 3}")
+		_:
+			print("wildcard")
 
 func test():
-    foo(0)
-    foo(1)
-    foo(2)
-    foo([1, 2])
-    foo(3)
-    foo(4)
-    foo([4,4])
-    foo({1 : 2, 2 : 3})
-    foo({1 : 2, 4 : 3})
+	foo(0)
+	foo(1)
+	foo(2)
+	foo([1, 2])
+	foo(3)
+	foo(4)
+	foo([4,4])
+	foo({1 : 2, 2 : 3})
+	foo({1 : 2, 4 : 3})

+ 3 - 3
modules/gdscript/tests/scripts/parser/features/lambda_callable.gd

@@ -1,4 +1,4 @@
 func test():
-    var my_lambda = func(x):
-        print(x)
-    my_lambda.call("hello")
+	var my_lambda = func(x):
+		print(x)
+	my_lambda.call("hello")

+ 38 - 38
modules/gdscript/tests/scripts/parser/features/match_dictionary.gd

@@ -1,43 +1,43 @@
 func foo(x):
-    match x:
-        {"key1": "value1", "key2": "value2"}:
-            print('{"key1": "value1", "key2": "value2"}')
-        {"key1": "value1", "key2"}:
-            print('{"key1": "value1", "key2"}')
-        {"key1", "key2": "value2"}:
-            print('{"key1", "key2": "value2"}')
-        {"key1", "key2"}:
-            print('{"key1", "key2"}')
-        {"key1": "value1"}:
-            print('{"key1": "value1"}')
-        {"key1"}:
-            print('{"key1"}')
-        _:
-            print("wildcard")
+	match x:
+		{"key1": "value1", "key2": "value2"}:
+			print('{"key1": "value1", "key2": "value2"}')
+		{"key1": "value1", "key2"}:
+			print('{"key1": "value1", "key2"}')
+		{"key1", "key2": "value2"}:
+			print('{"key1", "key2": "value2"}')
+		{"key1", "key2"}:
+			print('{"key1", "key2"}')
+		{"key1": "value1"}:
+			print('{"key1": "value1"}')
+		{"key1"}:
+			print('{"key1"}')
+		_:
+			print("wildcard")
 
 func bar(x):
-    match x:
-        {0}:
-            print("0")
-        {1}:
-            print("1")
-        {2}:
-            print("2")
-        _:
-            print("wildcard")
+	match x:
+		{0}:
+			print("0")
+		{1}:
+			print("1")
+		{2}:
+			print("2")
+		_:
+			print("wildcard")
 
 func test():
-    foo({"key1": "value1", "key2": "value2"})
-    foo({"key1": "value1", "key2": ""})
-    foo({"key1": "", "key2": "value2"})
-    foo({"key1": "", "key2": ""})
-    foo({"key1": "value1"})
-    foo({"key1": ""})
-    foo({"key1": "value1", "key2": "value2", "key3": "value3"})
-    foo({"key1": "value1", "key3": ""})
-    foo({"key2": "value2"})
-    foo({"key3": ""})
-    bar({0: "0"})
-    bar({1: "1"})
-    bar({2: "2"})
-    bar({3: "3"})
+	foo({"key1": "value1", "key2": "value2"})
+	foo({"key1": "value1", "key2": ""})
+	foo({"key1": "", "key2": "value2"})
+	foo({"key1": "", "key2": ""})
+	foo({"key1": "value1"})
+	foo({"key1": ""})
+	foo({"key1": "value1", "key2": "value2", "key3": "value3"})
+	foo({"key1": "value1", "key3": ""})
+	foo({"key2": "value2"})
+	foo({"key3": ""})
+	bar({0: "0"})
+	bar({1: "1"})
+	bar({2: "2"})
+	bar({3: "3"})

+ 20 - 20
modules/gdscript/tests/scripts/parser/features/match_multiple_patterns_with_array.gd

@@ -1,26 +1,26 @@
 func foo(x):
-    match x:
-        1, [2]:
-            print('1, [2]')
-        _:
-            print('wildcard')
+	match x:
+		1, [2]:
+			print('1, [2]')
+		_:
+			print('wildcard')
 
 func bar(x):
-    match x:
-        [1], [2], [3]:
-            print('[1], [2], [3]')
-        [4]:
-            print('[4]')
-        _:
-            print('wildcard')
+	match x:
+		[1], [2], [3]:
+			print('[1], [2], [3]')
+		[4]:
+			print('[4]')
+		_:
+			print('wildcard')
 
 func test():
-    foo(1)
-    foo([2])
-    foo(2)
-    bar([1])
-    bar([2])
-    bar([3])
-    bar([4])
-    bar([5])
+	foo(1)
+	foo([2])
+	foo(2)
+	bar([1])
+	bar([2])
+	bar([3])
+	bar([4])
+	bar([5])
 

+ 5 - 5
modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.gd

@@ -1,6 +1,6 @@
 func test():
-    match [1, 2, 3]:
-        [var a, var b, var c]:
-            print(a == 1)
-            print(b == 2)
-            print(c == 3)
+	match [1, 2, 3]:
+		[var a, var b, var c]:
+			print(a == 1)
+			print(b == 2)
+			print(c == 3)

+ 1 - 1
modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.gd

@@ -1,4 +1,4 @@
 const dictionary := {}
 
 func test():
-  dictionary.erase(0)
+	dictionary.erase(0)

+ 1 - 1
modules/gdscript/tests/scripts/runtime/features/array_string_stringname_equivalent.gd

@@ -9,7 +9,7 @@ func test():
 	array_sname.push_back(&"godot")
 	print("String in Array: ", "godot" in array_sname)
 
-  # Not equal because the values are different types.
+	# Not equal because the values are different types.
 	print("Arrays not equal: ", array_str != array_sname)
 
 	var string_array: Array[String] = []

+ 1 - 1
modules/gdscript/tests/scripts/runtime/features/dictionary_string_stringname_equivalent.gd

@@ -13,5 +13,5 @@ func test():
 	print("String gets StringName: ", stringname_dict.get("abc"))
 
 	stringname_dict[&"abc"] = 42
-  # They compare equal because StringName keys are converted to String.
+	# They compare equal because StringName keys are converted to String.
 	print("String Dictionary == StringName Dictionary: ", string_dict == stringname_dict)

+ 12 - 12
modules/gdscript/tests/scripts/runtime/features/parameter_shadowing.gd

@@ -3,23 +3,23 @@
 var a: int = 1
 
 func shadow_regular_assignment(a: Variant, b: Variant) -> void:
-  print(a)
-  print(self.a)
-  a = b
-  print(a)
-  print(self.a)
+	print(a)
+	print(self.a)
+	a = b
+	print(a)
+	print(self.a)
 
 
 var v := Vector2(0.0, 0.0)
 
 func shadow_subscript_assignment(v: Vector2, x: float) -> void:
-  print(v)
-  print(self.v)
-  v.x += x
-  print(v)
-  print(self.v)
+	print(v)
+	print(self.v)
+	v.x += x
+	print(v)
+	print(self.v)
 
 
 func test():
-  shadow_regular_assignment('a', 'b')
-  shadow_subscript_assignment(Vector2(1.0, 1.0), 5.0)
+	shadow_regular_assignment('a', 'b')
+	shadow_subscript_assignment(Vector2(1.0, 1.0), 5.0)