Repository: coala/coala

Issue:
Change default_coafile naming convention.
Should we change the name of `default_coafile` in `coalib` to `system_coafile`?
It will avoid confusion due to the following lines in `Constants.py`
```
system_coafile = os.path.join(coalib_root, 'default_coafile')

user_coafile = os.path.join(os.path.expanduser('~'), '.coarc')

default_coafile = '.coafile'
```


Discussion:
voting for this :+1:

I'm also thinking about `base_coafile` or something into this direction, but `system_coafile` is definitely an improvement we should take :+1:
`base_coafile` sounds great.

Also should we change a bit of naming convention in `ConfigurationGathering.py`?
The following part could be clearer:

```
    else:
        default_sections = load_config_file(Constants.system_coafile,
                                            log_printer)
        user_sections = load_config_file(
            Constants.user_coafile,
            log_printer,
            silent=True)

        default_config = str(
            default_sections['default'].get('config', '.coafile'))
        user_config = str(user_sections['default'].get(
            'config', default_config))
        config = os.path.abspath(
            str(cli_sections['default'].get('config', user_config)))
```

I say we change `default_sections` to `base_sections` or similar.
yeah default sections is definitely bad^^
There are just so many `defaults` :p 
Can I work on this?
Sure :) send a message on the gitter channel so one of the maintainers can assign you.
> Also should we change a bit of naming convention in ConfigurationGathering.py?
> The following part could be clearer:
>   ```
>    else:
>        default_sections = load_config_file(Constants.system_coafile,
>                                            log_printer)
>        user_sections = load_config_file(
>            Constants.user_coafile,
>            log_printer,
>            silent=True)
>
>        default_config = str(
>            default_sections['default'].get('config', '.coafile'))
>        user_config = str(user_sections['default'].get(
>            'config', default_config))
>        config = os.path.abspath(
>            str(cli_sections['default'].get('config', user_config)))
>   ```
> I say we change default_sections to base_sections or similar.

Migrated into separate issue: https://github.com/coala/coala/issues/3395
@lohani2280 Are you still working on the issue?
@nemaniarjun is someone working on this issue if not assign me.
@jack17529 feel free to take over ;) don't let the PR be wasted ;)
@nemaniarjun @Makman2 Can this issue be reassigned to me ?
Reassigning due to inactivity.
@acashmkj I would like to work on this if you are not working? Seems like PR has gone stale.
Reassigning due to inactivity.

Resolving patch:
diff --git a/coalib/misc/Constants.py b/coalib/misc/Constants.py
--- a/coalib/misc/Constants.py
+++ b/coalib/misc/Constants.py
@@ -3,6 +3,7 @@
 import appdirs
 import os
 import re
+import logging
 
 from coalib import VERSION
 
@@ -109,7 +110,17 @@
                                     'languages',
                                     'definitions')
 
-system_coafile = os.path.join(coalib_root, 'default_coafile')
+
+def get_system_coafile(coalib_root):
+    if os.path.isfile(os.path.join(coalib_root, 'system_coafile')):
+        return os.path.join(coalib_root, 'system_coafile')
+    else:
+        logging.warning('Filename deafult_coafile has been deprecated. '
+                        'Please use system_coafile instead.')
+        return os.path.join(coalib_root, 'default_coafile')
+
+
+system_coafile = get_system_coafile(coalib_root)
 
 user_coafile = os.path.join(os.path.expanduser('~'), '.coarc')
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -96,7 +96,7 @@ def run(self):
           packages=find_packages(exclude=['build.*', 'tests', 'tests.*']),
           install_requires=required,
           tests_require=test_required,
-          package_data={'coalib': ['default_coafile', 'VERSION',
+          package_data={'coalib': ['system_coafile', 'VERSION',
                                    'bearlib/languages/documentation/*.coalang']
                         },
           license='AGPL-3.0',


Test patch:
diff --git a/tests/settings/ConfigurationGatheringTest.py b/tests/settings/ConfigurationGatheringTest.py
--- a/tests/settings/ConfigurationGatheringTest.py
+++ b/tests/settings/ConfigurationGatheringTest.py
@@ -27,12 +27,14 @@
     load_configuration,
 )
 from coalib.settings.Setting import Setting
+from coalib.misc.Constants import get_system_coafile
 
 from tests.TestUtilities import (
     bear_test_module,
     TEST_BEARS_COUNT,
     TEST_BEAR_NAMES,
 )
+from testfixtures import log_capture
 
 
 @pytest.mark.usefixtures('disable_bears')
@@ -83,13 +85,27 @@ def test_gather_configuration(self):
 
         self.assertEqual(len(local_bears['cli']), 0)
 
-    def test_default_coafile_parsing(self):
+    @log_capture()
+    def test_default_coafile_deprecation(self, capture):
+        system_coafile_path = os.path.abspath(os.path.join(
+            os.path.dirname(os.path.realpath(__file__)),
+            'section_manager_test_files',
+            'child_dir'))
+
+        get_system_coafile(system_coafile_path)
+
+        capture.check(
+            ('root', 'WARNING', 'Filename deafult_coafile has been deprecated. '
+             'Please use system_coafile instead.')
+        )
+
+    def test_system_coafile_parsing(self):
         tmp = Constants.system_coafile
 
         Constants.system_coafile = os.path.abspath(os.path.join(
             os.path.dirname(os.path.realpath(__file__)),
             'section_manager_test_files',
-            'default_coafile'))
+            'system_coafile'))
 
         sections, local_bears, global_bears, targets = gather_configuration(
             lambda *args: True,
@@ -107,7 +123,7 @@ def test_user_coafile_parsing(self):
         Constants.user_coafile = os.path.abspath(os.path.join(
             os.path.dirname(os.path.realpath(__file__)),
             'section_manager_test_files',
-            'default_coafile'))
+            'system_coafile'))
 
         sections, local_bears, global_bears, targets = gather_configuration(
             lambda *args: True,
@@ -141,14 +157,14 @@ def test_merge(self):
         Constants.system_coafile = os.path.abspath(os.path.join(
             os.path.dirname(os.path.realpath(__file__)),
             'section_manager_test_files',
-            'default_coafile'))
+            'system_coafile'))
 
         config = os.path.abspath(os.path.join(
             os.path.dirname(os.path.realpath(__file__)),
             'section_manager_test_files',
             '.coafile'))
 
-        # Check merging of default_coafile and .coafile
+        # Check merging of system_coafile and .coafile
         sections, local_bears, global_bears, targets = gather_configuration(
             lambda *args: True,
             self.log_printer,
@@ -159,7 +175,7 @@ def test_merge(self):
         self.assertEqual(str(sections['test-2']),
                          "test-2 {files : '.', bears : 'LineCountBear'}")
 
-        # Check merging of default_coafile, .coafile and cli
+        # Check merging of system_coafile, .coafile and cli
         sections, local_bears, global_bears, targets = gather_configuration(
             lambda *args: True,
             self.log_printer,
diff --git a/tests/settings/section_manager_test_files/default_coafile b/tests/settings/section_manager_test_files/child_dir/default_coafile
similarity index 100%
rename from tests/settings/section_manager_test_files/default_coafile
rename to tests/settings/section_manager_test_files/child_dir/default_coafile
diff --git a/tests/settings/section_manager_test_files/system_coafile b/tests/settings/section_manager_test_files/system_coafile
new file mode 100644
--- /dev/null
+++ b/tests/settings/section_manager_test_files/system_coafile
@@ -0,0 +1,8 @@
+config = tests/settings/section_manager_test_files/other_coafile
+[test]
+value = 1
+[test-2]
+files =
+bears = LineCountBear,testBear
+[test-3]
+files = MakeFile