Repository: wemake-services/wemake-python-styleguide

Issue:
Incorrect error message when over-using empty string
# Bug report

<!--
Hi, thanks for submitting a bug. We appreciate that.

But, we will need some information about what's wrong to help you.
-->

## What's wrong

Right now:

> hooks/post_gen_project.py:0:1: Z226 Found string constant over-use: 

## How is that should be

> hooks/post_gen_project.py:0:1: Z226 Found string constant over-use: ''

I am using `0.10`


Discussion:
Hey!
I wrote a new test. And test falls.
```
 assert "Z226 Found s... over-use: ''" == 'Z226 Found st...nt over-use: '
E         - Z226 Found string constant over-use: ''
E         ?                                      --
E         + Z226 Found string constant over-use:
```
I add the following rule to the code
```python
 def _post_visit(self) -> None:
        for string, usage_count in self._string_constants.items():
            if not len(string):
                string = "''"
            if usage_count > self.options.max_string_usages:
                self.add_violation(OverusedStringViolation(text=string))
```
Then the previous test falls.
How to catch an empty line for a visitor?
I would simplify your code to:

```python
def _post_visit(self) -> None:
        for string, usage_count in self._string_constants.items():
            if usage_count > self.options.max_string_usages:
                self.add_violation(OverusedStringViolation(text=string or "''"))
```

That's it. Tests should just be fixed. Make sure that `assert_error_text` works.

Resolving patch:
diff --git a/wemake_python_styleguide/visitors/ast/builtins.py b/wemake_python_styleguide/visitors/ast/builtins.py
--- a/wemake_python_styleguide/visitors/ast/builtins.py
+++ b/wemake_python_styleguide/visitors/ast/builtins.py
@@ -45,7 +45,7 @@ def _check_string_constant(self, node: ast.Str) -> None:
     def _post_visit(self) -> None:
         for string, usage_count in self._string_constants.items():
             if usage_count > self.options.max_string_usages:
-                self.add_violation(OverusedStringViolation(text=string))
+                self.add_violation(OverusedStringViolation(text=string or "''"))
 
     def visit_Str(self, node: ast.Str) -> None:
         """


Test patch:
diff --git a/tests/test_visitors/test_ast/test_builtins/test_strings/test_overused_string.py b/tests/test_visitors/test_ast/test_builtins/test_strings/test_overused_string.py
--- a/tests/test_visitors/test_ast/test_builtins/test_strings/test_overused_string.py
+++ b/tests/test_visitors/test_ast/test_builtins/test_strings/test_overused_string.py
@@ -1,5 +1,7 @@
 # -*- coding: utf-8 -*-
 
+import pytest
+
 from wemake_python_styleguide.violations.complexity import (
     OverusedStringViolation,
 )
@@ -12,16 +14,20 @@
 'new' + {0}
 """
 
-string_value = '"same-string"'
-
 
+@pytest.mark.parametrize('strings', [
+    string_actions,
+])
+@pytest.mark.parametrize('string_value', ['"same_string"'])
 def test_string_overuse_settings(
     assert_errors,
     parse_ast_tree,
     options,
+    strings,
+    string_value,
 ):
     """Ensures that settings for string over-use work."""
-    tree = parse_ast_tree(string_actions.format('"same-string"'))
+    tree = parse_ast_tree(strings.format(string_value))
 
     option_values = options(max_string_usages=4)
     visitor = WrongStringVisitor(option_values, tree=tree)
@@ -30,14 +36,23 @@ def test_string_overuse_settings(
     assert_errors(visitor, [])
 
 
+@pytest.mark.parametrize('strings', [
+    string_actions,
+])
+@pytest.mark.parametrize('string_value', [
+    '"same-string"',
+    "''",
+])
 def test_string_overuse(
     assert_errors,
     assert_error_text,
     parse_ast_tree,
     default_options,
+    strings,
+    string_value,
 ):
     """Ensures that over-used strings raise violations."""
-    tree = parse_ast_tree(string_actions.format(string_value))
+    tree = parse_ast_tree(strings.format(string_value))
 
     visitor = WrongStringVisitor(default_options, tree=tree)
     visitor.run()