Repository: coala/coala

Issue:
glob patterns with multiple ** incorrectly cause warnings
With a `.coafile` like

```
ignore =
  .git/,
  **/migrations/**,
```

warnings like the following occur:

[WARNING][02:36:51] Detected trailing globstar in ignore glob '/builds/.../**/migrations/**'. Please remove the unnecessary '**' from its end.

The trailing `**` are unnecessary only if the rest of the path is a canonical directory not containing any wildcards.


Discussion:
Would love to take this one up @jayvdb :D 
Seems like a natural continuation of my previous PR :stuck_out_tongue_closed_eyes: 

Resolving patch:
diff --git a/coalib/collecting/Collectors.py b/coalib/collecting/Collectors.py
--- a/coalib/collecting/Collectors.py
+++ b/coalib/collecting/Collectors.py
@@ -12,7 +12,7 @@
 from coalib.misc.Exceptions import log_exception
 from coalib.misc.IterUtilities import partition
 from coalib.output.printers.LOG_LEVEL import LOG_LEVEL
-from coalib.parsing.Globbing import fnmatch, iglob, glob_escape
+from coalib.parsing.Globbing import fnmatch, iglob, glob_escape, has_wildcard
 from coalib.bearlib.languages.Language import Languages
 from coalib.bearlib.languages import definitions
 
@@ -73,7 +73,8 @@ def icollect(file_paths, ignored_globs=None, match_cache={},
     if ignored_globs is None:
         ignored_globs = []
     for index, glob in enumerate(ignored_globs):
-        if glob.endswith('/**') or glob.endswith('\\**'):
+        dirname, basename = os.path.split(glob)
+        if not has_wildcard(dirname) and basename == '**':
             logging.warning("Detected trailing globstar in ignore glob '{}'. "
                             "Please remove the unnecessary '**' from its end."
                             .format(glob))


Test patch:
diff --git a/tests/collecting/CollectorsTest.py b/tests/collecting/CollectorsTest.py
--- a/tests/collecting/CollectorsTest.py
+++ b/tests/collecting/CollectorsTest.py
@@ -117,19 +117,23 @@ def dir_base(*args):
             [dir_base('c_files', 'file1.c')])
 
     def test_trailing_globstar(self):
-        ignore_path = os.path.join(self.collectors_test_dir,
-                                   'others',
-                                   'c_files',
-                                   '**')
+        ignore_path1 = os.path.join(self.collectors_test_dir,
+                                    'others',
+                                    'c_files',
+                                    '**')  # should generate warning
+        ignore_path2 = os.path.join(self.collectors_test_dir,
+                                    '**',
+                                    'py_files',
+                                    '**')  # no warning
         with LogCapture() as capture:
             collect_files(file_paths=[],
-                          ignored_file_paths=[ignore_path],
+                          ignored_file_paths=[ignore_path1, ignore_path2],
                           log_printer=self.log_printer)
         capture.check(
             ('root', 'WARNING', 'Detected trailing globstar in ignore glob '
                                 '\'{}\'. Please remove the unnecessary \'**\''
                                 ' from its end.'
-                                .format(ignore_path))
+                                .format(ignore_path1))
         )
 
     def test_limited(self):