Repository: sqlfluff/sqlfluff

Issue:
Strip newlines in exclude_rules
To make diffs in .sqlfluff look better for `exclude_rules` it would be nice to support newlines. 

For example

```txt
[sqlfluff]
exclude_rules = L011,L022,L031,
```

should be able to be rewritten as

```txt
[sqlfluff]
exclude_rules = 
    L011,
    L022,
    L031,
```

This would involve adding a `.strip()` to the following line:

https://github.com/sqlfluff/sqlfluff/blob/master/src/sqlfluff/core/config.py#L418

Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 553356412..17ba14da0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ### Changed
 
 - Added dbt 0.20.* to the default test suite.
+- Handle newlines in rule list configuration in .sqlfluff [#1215](https://github.com/sqlfluff/sqlfluff/issues/1215)
 
 ## [0.6.1] - 2021-07-16
 ### Added
diff --git a/src/sqlfluff/core/config.py b/src/sqlfluff/core/config.py
index 0913e5a57..9fb5fa58a 100644
--- a/src/sqlfluff/core/config.py
+++ b/src/sqlfluff/core/config.py
@@ -402,20 +402,24 @@ class FluffConfig:
         )
         # Deal with potential ignore parameters
         if self._configs["core"].get("ignore", None):
-            self._configs["core"]["ignore"] = self._configs["core"]["ignore"].split(",")
+            self._configs["core"]["ignore"] = self._split_comma_separated_string(
+                self._configs["core"]["ignore"]
+            )
         else:
             self._configs["core"]["ignore"] = []
         # Whitelists and blacklists
         if self._configs["core"].get("rules", None):
-            self._configs["core"]["rule_whitelist"] = self._configs["core"][
-                "rules"
-            ].split(",")
+            self._configs["core"][
+                "rule_whitelist"
+            ] = self._split_comma_separated_string(self._configs["core"]["rules"])
         else:
             self._configs["core"]["rule_whitelist"] = None
         if self._configs["core"].get("exclude_rules", None):
-            self._configs["core"]["rule_blacklist"] = self._configs["core"][
-                "exclude_rules"
-            ].split(",")
+            self._configs["core"][
+                "rule_blacklist"
+            ] = self._split_comma_separated_string(
+                self._configs["core"]["exclude_rules"]
+            )
         else:
             self._configs["core"]["rule_blacklist"] = None
         # Configure Recursion
@@ -606,3 +610,7 @@ class FluffConfig:
             if raw_line.startswith("-- sqlfluff"):
                 # Found a in-file config command
                 self.process_inline_config(raw_line)
+
+    @staticmethod
+    def _split_comma_separated_string(raw_str: str) -> List[str]:
+        return [s.strip() for s in raw_str.split(",") if s.strip()]


Test patch:
diff --git a/test/core/config_test.py b/test/core/config_test.py
index d0eaabf44..087bfda46 100644
--- a/test/core/config_test.py
+++ b/test/core/config_test.py
@@ -183,3 +183,15 @@ def test__config__load_user_appdir_config(
             call(os.path.expanduser("~/Library/Application Support/sqlfluff")),
         ]
     )
+
+
+@pytest.mark.parametrize(
+    "raw_str, expected",
+    [
+        ("L011,L022,L031", ["L011", "L022", "L031"]),
+        ("\nL011,\nL022,\nL031,", ["L011", "L022", "L031"]),
+    ],
+)
+def test__config___split_comma_separated_string(raw_str, expected):
+    """Tests that comma separated string config is handled correctly."""
+    assert FluffConfig._split_comma_separated_string(raw_str) == expected