Repository: editorconfig-checker/editorconfig-checker
Pull request #386 (2024-10-05 07:47:33)

fix: typo in config, `SpacesAftertabs` => `SpacesAfterTabs`
#247 

> I think we should rather change this in the code to be SpacesAfterTabs as this is the more accurate name.
Would you be willing to provide a PR for this too?

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/editorconfig-checker/editorconfig-checker/pull/386?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=editorconfig-checker) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 86.83%. Comparing base [(`6d109c9`)](https://app.codecov.io/gh/editorconfig-checker/editorconfig-checker/commit/6d109c9e77945f6a961a693d248c77c761ffb5a8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=editorconfig-checker) to head [(`505943e`)](https://app.codecov.io/gh/editorconfig-checker/editorconfig-checker/commit/505943efbcc75e3b6833111caaf2d6337db212f1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=editorconfig-checker).

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main     #386   +/-   ##
=======================================
  Coverage   86.83%   86.83%           
=======================================
  Files          10       10           
  Lines         699      699           
=======================================
  Hits          607      607           
  Misses         63       63           
  Partials       29       29           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/editorconfig-checker/editorconfig-checker/pull/386?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=editorconfig-checker).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=editorconfig-checker).

hituzi-no-sippo: Thanks for your review.

I have the above two questions.
Would you mind answering them if you don't mind?
I am a beginner in Golang. So I don't know what to do about the above two points.
klaernie: As much as it pains me (because I will have to rebase something ;) ) it's a good change to have! Thanks for implementing, @hituzi-no-sippo!

Patch:
diff --git a/.ecrc b/.ecrc
index bbba5ea..1a3dedd 100644
--- a/.ecrc
+++ b/.ecrc
@@ -3,7 +3,7 @@
   "Verbose": false,
   "Debug": false,
   "IgnoreDefaults": false,
-  "SpacesAftertabs": false,
+  "SpacesAfterTabs": false,
   "NoColor": false,
   "exclude": [
     "testfiles",
diff --git a/README.md b/README.md
index 10557b5..de85d94 100644
--- a/README.md
+++ b/README.md
@@ -182,7 +182,7 @@ A sample configuration file can look like this and will be used from your curren
   "Verbose": false,
   "Debug": false,
   "IgnoreDefaults": false,
-  "SpacesAftertabs": false,
+  "SpacesAfterTabs": false,
   "NoColor": false,
   "Exclude": [],
   "AllowedContentTypes": [],
diff --git a/pkg/config/config.go b/pkg/config/config.go
index e82307d..1919ae8 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -90,7 +90,8 @@ type Config struct {
 	Format              outputformat.OutputFormat
 	Debug               bool
 	IgnoreDefaults      bool
-	SpacesAftertabs     bool
+	SpacesAftertabs     *bool
+	SpacesAfterTabs     bool
 	NoColor             bool
 	Exclude             []string
 	AllowedContentTypes []string
@@ -203,8 +204,14 @@ func (c *Config) Merge(config Config) {
 		c.IgnoreDefaults = config.IgnoreDefaults
 	}
 
-	if config.SpacesAftertabs {
-		c.SpacesAftertabs = config.SpacesAftertabs
+	if config.SpacesAftertabs != nil {
+		c.Logger.Warning("The configuration key `SpacesAftertabs` is deprecated. Use `SpacesAfterTabs` instead.")
+
+		c.SpacesAfterTabs = *config.SpacesAftertabs
+	}
+
+	if config.SpacesAfterTabs {
+		c.SpacesAfterTabs = config.SpacesAfterTabs
 	}
 
 	if config.Path != "" {
@@ -280,7 +287,7 @@ func (c Config) Save(version string) error {
 		Format              string
 		Debug               bool
 		IgnoreDefaults      bool
-		SpacesAftertabs     bool
+		SpacesAfterTabs     bool
 		NoColor             bool
 		Exclude             []string
 		AllowedContentTypes []string
diff --git a/pkg/validation/validators/validators.go b/pkg/validation/validators/validators.go
index 14a0739..ea22f09 100644
--- a/pkg/validation/validators/validators.go
+++ b/pkg/validation/validators/validators.go
@@ -62,7 +62,7 @@ func Tab(line string, config config.Config) error {
 
 		regexpPattern := "^(\t)*( \\* ?|[^ \t]|$)"
 
-		if config.SpacesAftertabs {
+		if config.SpacesAfterTabs {
 			regexpPattern = "(^(\t)*\\S)|(^(\t)+( )*\\S)|(^ \\S)"
 		}
 


Test patch:
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index 04a3fed..abbd970 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -120,7 +120,7 @@ func TestMerge(t *testing.T) {
 		Debug:               true,
 		NoColor:             true,
 		IgnoreDefaults:      true,
-		SpacesAftertabs:     true,
+		SpacesAfterTabs:     true,
 		Exclude:             []string{"some-other"},
 		PassedFiles:         []string{"src"},
 		AllowedContentTypes: []string{"xml/"},
@@ -175,7 +175,7 @@ func TestParse(t *testing.T) {
 		c.IgnoreDefaults != true ||
 		!reflect.DeepEqual(c.Exclude, []string{"testfiles"}) ||
 		!reflect.DeepEqual(c.AllowedContentTypes, []string{"text/", "application/octet-stream", "application/ecmascript", "application/json", "application/x-ndjson", "application/xml", "+json", "+xml", "hey"}) ||
-		c.SpacesAftertabs != true ||
+		c.SpacesAfterTabs != true ||
 		c.Disable.EndOfLine != false ||
 		c.Disable.TrimTrailingWhitespace != false ||
 		c.Disable.InsertFinalNewline != false ||
@@ -204,7 +204,7 @@ func TestGetAsString(t *testing.T) {
 	_ = c.Parse()
 
 	actual := c.GetAsString()
-	expected := "Config: {ShowVersion:false Help:false DryRun:false Path:../../.ecrc Version:v3.0.3 Verbose:false Format: Debug:false IgnoreDefaults:false SpacesAftertabs:false NoColor:false Exclude:[testfiles testdata] AllowedContentTypes:[text/ application/octet-stream application/ecmascript application/json application/x-ndjson application/xml +json +xml] PassedFiles:[] Disable:{EndOfLine:false Indentation:false InsertFinalNewline:false TrimTrailingWhitespace:false IndentSize:false MaxLineLength:false} Logger:{Verbosee:false Debugg:false NoColor:false} EditorconfigConfig:0x"
+	expected := "Config: {ShowVersion:false Help:false DryRun:false Path:../../.ecrc Version:v3.0.3 Verbose:false Format: Debug:false IgnoreDefaults:false SpacesAftertabs:<nil> SpacesAfterTabs:false NoColor:false Exclude:[testfiles testdata] AllowedContentTypes:[text/ application/octet-stream application/ecmascript application/json application/x-ndjson application/xml +json +xml] PassedFiles:[] Disable:{EndOfLine:false Indentation:false InsertFinalNewline:false TrimTrailingWhitespace:false IndentSize:false MaxLineLength:false} Logger:{Verbosee:false Debugg:false NoColor:false} EditorconfigConfig:0x"
 
 	if !strings.HasPrefix(actual, expected) {
 		t.Errorf("Expected: %v, got: %v ", expected, actual)
diff --git a/pkg/validation/validation_test.go b/pkg/validation/validation_test.go
index 9f89ff0..afce5a9 100644
--- a/pkg/validation/validation_test.go
+++ b/pkg/validation/validation_test.go
@@ -51,13 +51,13 @@ func TestValidateFile(t *testing.T) {
 		t.Error("Should have no errors, got", result)
 	}
 
-	configuration = config.Config{SpacesAftertabs: true}
+	configuration = config.Config{SpacesAfterTabs: true}
 	result = ValidateFile("./../../testfiles/spaces-after-tabs.txt", configuration)
 	if len(result) != 0 {
 		t.Error("Should have no errors when validating valid file, got", result)
 	}
 
-	configuration = config.Config{SpacesAftertabs: false}
+	configuration = config.Config{SpacesAfterTabs: false}
 	result = ValidateFile("./../../testfiles/zero-indent.txt", configuration)
 	if len(result) != 0 {
 		t.Error("Should have no errors when validating valid file, got", result)
@@ -83,7 +83,7 @@ func TestValidateFile(t *testing.T) {
 		t.Error("Should have one error, got", result)
 	}
 
-	configuration = config.Config{SpacesAftertabs: false}
+	configuration = config.Config{SpacesAfterTabs: false}
 	result = ValidateFile("./../../testfiles/spaces-after-tabs.txt", configuration)
 	if len(result) != 1 {
 		t.Error("Should have one error, got", result)
diff --git a/pkg/validation/validators/validators_test.go b/pkg/validation/validators/validators_test.go
index feb7ca6..64e2e41 100644
--- a/pkg/validation/validators/validators_test.go
+++ b/pkg/validation/validators/validators_test.go
@@ -115,7 +115,7 @@ func TestLineEnding(t *testing.T) {
 }
 
 func TestIndentation(t *testing.T) {
-	configuration := config.Config{SpacesAftertabs: false}
+	configuration := config.Config{SpacesAfterTabs: false}
 
 	indentationTests := []struct {
 		line        string
@@ -183,8 +183,8 @@ func TestSpace(t *testing.T) {
 }
 
 func TestTab(t *testing.T) {
-	spacesAllowed := config.Config{SpacesAftertabs: true}
-	spacesForbidden := config.Config{SpacesAftertabs: false}
+	spacesAllowed := config.Config{SpacesAfterTabs: true}
+	spacesForbidden := config.Config{SpacesAfterTabs: false}
 	tabTests := []struct {
 		line     string
 		config   config.Config
diff --git a/testfiles/generated-config.json b/testfiles/generated-config.json
index 0264a5b..4a47dc3 100644
--- a/testfiles/generated-config.json
+++ b/testfiles/generated-config.json
@@ -4,7 +4,7 @@
   "Format": "",
   "Debug": false,
   "IgnoreDefaults": false,
-  "SpacesAftertabs": false,
+  "SpacesAfterTabs": false,
   "NoColor": false,
   "Exclude": [],
   "AllowedContentTypes": [],