Repository: spyder-ide/spyder

Issue:
Strange behavior for Spyder code annotations
<!--- **PLEASE READ:** Before submitting here, please carefully consult our *Troubleshooting Guide* at https://github.com/spyder-ide/spyder/wiki/Troubleshooting-Guide-and-FAQ and search the issues page for your error/problem, as most posted bugs are duplicates or easy fixes.

If you don't find anything, please provide a detailed step-by-step description (in English) of the problem and what led up to it below. Issue reports without a clear way to reproduce them will be closed. Thanks! --->

## Problem Description
Using comments such as #TIPS and #HINTS will render a blue checkmark in the Spyder IDE. If you go to <kbd>Tools|Editor|Code Introspection/Analysis</kbd> and activate <kbd>Code Annotations (TODO, FIXME, XXX, HINT, TIP...)</kbd>, those keywords do not seem to trigger any effect in the SPyder IDE at all. 


### What steps will reproduce the problem?

1.  Go to Tools|Editor|Code Introspection/Analysis
2. Activate Code Annotations (TODO, FIXME, XXX, HINT, TIP...)
3. No blue checkmarks activated.

### What is the expected output? What do you see instead?
Covered in the Problem Description.


### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback

PASTE TRACEBACK HERE

```

## Package Versions

* Spyder: 3.2.5
* Python: 3.6.0
* Qt:
* PyQt:
* Operating System: Windows

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

```
PASTE DEPENDENCIES HERE
```



Discussion:
Thanks for reporting. We'll take a loot at this for 3.2.8
Can you give more of an example of what you are entering in order to get the blue checkmark?  For example, I noticed that 
```
# XXX
```
does not give a checkmark, but
```
# XXX - come back later
```
does.  I think the code checks that the comment has more text on the line than just the TODO, FIXME, etc.




Resolving patch:
diff --git a/spyder/utils/codeanalysis.py b/spyder/utils/codeanalysis.py
--- a/spyder/utils/codeanalysis.py
+++ b/spyder/utils/codeanalysis.py
@@ -33,7 +33,9 @@ def find_tasks(source_code):
     results = []
     for line, text in enumerate(source_code.splitlines()):
         for todo in re.findall(TASKS_PATTERN, text):
-            results.append((todo[-1].strip().capitalize(), line+1))
+            todo_text = (todo[-1].strip(' :').capitalize() if todo[-1]
+                         else todo[-2])
+            results.append((todo_text, line + 1))
     return results
 
 


Test patch:
diff --git a/spyder/utils/tests/data/example.py b/spyder/utils/tests/data/example.py
--- a/spyder/utils/tests/data/example.py
+++ b/spyder/utils/tests/data/example.py
@@ -10,6 +10,9 @@
 
 import numpy as np
 
+# TODO test
+# XXX
+
 print (__file__)
 
 def iterate_1(Z):
diff --git a/spyder/utils/tests/test_codeanalysis.py b/spyder/utils/tests/test_codeanalysis.py
--- a/spyder/utils/tests/test_codeanalysis.py
+++ b/spyder/utils/tests/test_codeanalysis.py
@@ -27,9 +27,9 @@ def test_codeanalysis():
     check_results = check_with_pyflakes(code, TEST_FILE) + \
                     check_with_pep8(code, TEST_FILE) + find_tasks(code)
     if PY2:
-        num_results = 87
+        num_results = 89
     else:
-        num_results = 88
+        num_results = 90
     assert len(check_results) == num_results
 
 
diff --git a/spyder/utils/tests/test_get_words.py b/spyder/utils/tests/test_get_words.py
--- a/spyder/utils/tests/test_get_words.py
+++ b/spyder/utils/tests/test_get_words.py
@@ -60,7 +60,7 @@ def test_get_words_python():
                       'com', 'def', 'for', 'gmail', 'home', 'i', 'implemented', 'import',
                       'in', 'int', 'is', 'iterate_', 'jmg', 'neighbours', 'new', 'np', 'null',
                       'numpy', 'over', 'print', 'range', 'ravel', 'return', 'rules', 'shape',
-                      'stay', 'sure', 'survive', 'utn', 'values', 'zeros']
+                      'stay', 'sure', 'survive', 'test', 'TODO', 'utn', 'values', 'XXX', 'zeros']
     assert sorted(expected_words) == sorted(get_words_by_filename("example.py"))
     assert sorted(expected_words) == sorted(get_words_by_content("example.py"))