internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: oppia/oppia

Issue:
Enable _check_directive_scope function and fix corresponding problems
The `_check_directive_scope` function (PR #4848) should be enabled after the corresponding fixes are made. This issue keeps a track of the same.


Discussion:

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -127,6 +127,15 @@
             'extensions/objects/',
             'extensions/value_generators/',
             'extensions/visualizations/')
+    },
+    {
+        'regexp': r"\$parent",
+        'message': "Please do not access parent properties " +
+                   "using $parent. Use the scope object" +
+                   "for this purpose.",
+        'excluded_files': (
+            'core/templates/dev/head/app.js'),
+        'excluded_dirs': ()
     }
 ]
 
@@ -1194,8 +1203,7 @@ def _check_html_indent(all_files):
 
 def main():
     all_files = _get_all_files()
-    # TODO(apb7): Enable the _check_directive_scope function.
-    directive_scope_messages = []
+    directive_scope_messages = _check_directive_scope(all_files)
     html_directive_name_messages = _check_html_directive_name(all_files)
     import_order_messages = _check_import_order(all_files)
     newline_messages = _check_newline_character(all_files)


Test patch:
Repository: oppia/oppia

Issue:
Stylinter fails on lint checks.
**Steps to reproduce:**
- Change any of the *.html files.
- run `python scripts/pre_commit_linter.py`

**Error log:**
![screenshot from 2018-06-12 07 33 11](https://user-images.githubusercontent.com/16653571/41503893-6cee00f6-71fc-11e8-831a-7ae1ba01066b.png)

/cc @seanlip, @apb7 & @kevintab95 


Discussion:

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -320,10 +320,12 @@ def _get_all_files_in_directory(dir_path, excluded_glob_patterns):
     return files_in_directory
 
 
-def _lint_css_files(stylelint_path, config_path, files_to_lint, stdout, result):
+def _lint_css_files(
+        node_path, stylelint_path, config_path, files_to_lint, stdout, result):
     """Prints a list of lint errors in the given list of CSS files.
 
     Args:
+        node_path: str. Path to the node binary.
         stylelint_path: str. Path to the Stylelint binary.
         config_path: str. Path to the configuration file.
         files_to_lint: list(str). A list of filepaths to lint.
@@ -341,7 +343,7 @@ def _lint_css_files(stylelint_path, config_path, files_to_lint, stdout, result):
 
     print 'Total css files: ', num_css_files
     stylelint_cmd_args = [
-        stylelint_path, '--config=' + config_path]
+        node_path, stylelint_path, '--config=' + config_path]
     for _, filename in enumerate(files_to_lint):
         print 'Linting: ', filename
         proc_args = stylelint_cmd_args + [filename]
@@ -617,6 +619,7 @@ def _pre_commit_linter(all_files):
     linting_processes = []
     linting_processes.append(multiprocessing.Process(
         target=_lint_css_files, args=(
+            node_path,
             stylelint_path,
             config_path_for_css_in_html,
             html_files_to_lint_for_css, css_in_html_stdout,
@@ -627,6 +630,7 @@ def _pre_commit_linter(all_files):
 
     linting_processes.append(multiprocessing.Process(
         target=_lint_css_files, args=(
+            node_path,
             stylelint_path,
             config_path_for_oppia_css,
             css_files_to_lint, css_stdout,


Test patch:
Repository: oppia/oppia

Issue:
Remove app.js from excluded_files for BAD_PATTERNS_JS_REGEXP
We are currently in the process of setting up a check for `$parent` for JS files. In general, `$parent` should not be used throughout the code base, instead the `scope` object should be used to access parent properties.
At the moment, [app.js](https://github.com/oppia/oppia/blob/develop/core/templates/dev/head/app.js) is being added to `excluded_files` for this particular regex check since the only `$parent` statements in this file are in reference to `textAngular` which is being upgraded to `CKEditor`. Therefore they will be removed by the end of the @bansalnitish's project.
This issue serves as a reminder to remove app.js from `excluded_files` once the project is completed.
Remove app.js from excluded_files for BAD_PATTERNS_JS_REGEXP
We are currently in the process of setting up a check for `$parent` for JS files. In general, `$parent` should not be used throughout the code base, instead the `scope` object should be used to access parent properties.
At the moment, [app.js](https://github.com/oppia/oppia/blob/develop/core/templates/dev/head/app.js) is being added to `excluded_files` for this particular regex check since the only `$parent` statements in this file are in reference to `textAngular` which is being upgraded to `CKEditor`. Therefore they will be removed by the end of the @bansalnitish's project.
This issue serves as a reminder to remove app.js from `excluded_files` once the project is completed.


Discussion:

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -144,8 +144,7 @@
         'message': "Please do not access parent properties " +
                    "using $parent. Use the scope object" +
                    "for this purpose.",
-        'excluded_files': (
-            'core/templates/dev/head/app.js'),
+        'excluded_files': (),
         'excluded_dirs': ()
     }
 ]


Test patch:
Repository: oppia/oppia

Issue:
Fix follow-up comments from #5153.
This is just an issue to track fixing the follow-up comments from #5153.

/cc @vojtechjelinek 


Discussion:
Hi @ishucr7. Is this resolved yet? 

Resolving patch:
diff --git a/core/domain/exp_jobs_one_off.py b/core/domain/exp_jobs_one_off.py
--- a/core/domain/exp_jobs_one_off.py
+++ b/core/domain/exp_jobs_one_off.py
@@ -665,7 +665,7 @@ def map(file_snapshot_content_model):
                         ALLOWED_IMAGE_EXTENSIONS) + '))$')
                 catched_groups = pattern.match(instance_id)
                 if not catched_groups:
-                    yield(WRONG_INSTANCE_ID, instance_id)
+                    yield (WRONG_INSTANCE_ID, instance_id)
                 else:
                     filename = catched_groups.group(2)
                     filepath = 'assets/' + filename
@@ -676,20 +676,20 @@ def map(file_snapshot_content_model):
                         content = file_model.content
                         fs = fs_domain.AbstractFileSystem(
                             fs_domain.GcsFileSystem(exploration_id))
-                        if fs.isfile('image/%s' % (filename)):
-                            yield(FILE_ALREADY_EXISTS, file_model.id)
+                        if fs.isfile('image/%s' % filename):
+                            yield (FILE_ALREADY_EXISTS, file_model.id)
                         else:
                             fs.commit(
-                                'ADMIN', 'image/%s' % (filename),
-                                content, 'image/%s' % (filetype))
-                            yield(FILE_COPIED, 1)
+                                'ADMIN', 'image/%s' % filename,
+                                content, 'image/%s' % filetype)
+                            yield (FILE_COPIED, 1)
                     else:
-                        yield(FOUND_DELETED_FILE, file_model.id)
+                        yield (FOUND_DELETED_FILE, file_model.id)
 
 
     @staticmethod
     def reduce(status, values):
         if status == FILE_COPIED:
-            yield(status, len(values))
+            yield (status, len(values))
         else:
-            yield(status, values)
+            yield (status, values)
diff --git a/core/domain/fs_domain.py b/core/domain/fs_domain.py
--- a/core/domain/fs_domain.py
+++ b/core/domain/fs_domain.py
@@ -457,7 +457,7 @@ def isfile(self, filepath):
             filepath: str. The path to the relevant file within the exploration.
 
         Returns:
-            bool. Returns True if the file exists in GCS else False.
+            bool. Whether the file exists in GCS.
         """
         bucket_name = app_identity_services.get_gcs_resource_bucket_name()
 


Test patch:
Repository: oppia/oppia

Issue:
Set default value of the dropdown to direct the learner in 'Add Response' modal
## Repro Steps:
* Open Creator Dashboard and click 'create' button to create new exploration.
* Choose any of the interaction.
* See the 'Add Response' modal that appears after selecting the interaction.

## Observed behaviour:
* See dropdown below 'directs the learner to ...'.
* It's default value isn't set.
![screen shot 2018-08-04 at 12 55 44 pm](https://user-images.githubusercontent.com/26625980/43678427-d18370aa-9830-11e8-84a0-e987025e7d50.png)

## Expected behaviour:
Default value should be set as it was previously. Note that this bug may be introduced recently.
![screen shot 2018-08-04 at 12 55 05 pm](https://user-images.githubusercontent.com/26625980/43678441-023bb64e-9831-11e8-9d09-8a5e60c46583.png)
 


Discussion:

Resolving patch:
diff --git a/core/domain/stats_services.py b/core/domain/stats_services.py
--- a/core/domain/stats_services.py
+++ b/core/domain/stats_services.py
@@ -104,7 +104,6 @@ def get_exploration_stats(exp_id, exp_version):
         ExplorationStats. The exploration stats domain object.
     """
     exploration_stats = get_exploration_stats_by_id(exp_id, exp_version)
-
     if exploration_stats is None:
         exploration_stats = stats_domain.ExplorationStats.create_default(
             exp_id, exp_version, {})


Test patch:
Repository: oppia/oppia

Issue:
Add lint check to detect merge issues
We should add a lint check that detects strings like ">>>>>" and "<<<<<" that appear during merge conflicts. This issue arises because there recently were some incorrect merge conflict resolution PRs that were not caught, and that should have been, e.g. https://github.com/oppia/oppia/commit/3473191c1ea78c8e987da38623c32d8a26c81ae8#diff-638d9eb848163610ca313018fd336a66R572

/cc @apb7 

Add lint check to detect merge issues
We should add a lint check that detects strings like ">>>>>" and "<<<<<" that appear during merge conflicts. This issue arises because there recently were some incorrect merge conflict resolution PRs that were not caught, and that should have been, e.g. https://github.com/oppia/oppia/commit/3473191c1ea78c8e987da38623c32d8a26c81ae8#diff-638d9eb848163610ca313018fd336a66R572

/cc @apb7 



Discussion:

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -92,6 +92,14 @@
         'message': 'Please make sure all files only have LF endings (no CRLF).',
         'excluded_files': (),
         'excluded_dirs': ()},
+    '<<<<<<<': {
+        'message': 'Please fully resolve existing merge conflicts.',
+        'excluded_files': (),
+        'excluded_dirs': ()},
+    '>>>>>>>': {
+        'message': 'Please fully resolve existing merge conflicts.',
+        'excluded_files': (),
+        'excluded_dirs': ()},
     'glyphicon': {
         'message': 'Please use equivalent material-icons '
                    'instead of glyphicons.',


Test patch:
Repository: oppia/oppia

Issue:
Lint check for pylint-disable
In [this PR](https://github.com/oppia/oppia/pull/5582/files#diff-47320e1c0a2e765ffd35d070966fd6e0R129), the author uses the construct `# pylint: disable=W0212`. This is hard to understand and it would be better to use the human-readable name instead.

It would be nice if we could detect such messages ('disable=[A-Z][0-9]{4}') and request (via a lint check) that the developer either remove the necessity for the lint exclusion altogether, or else use the human-readable version of the error code (and give them some guidance on where to find this human-readable version).


Lint check for pylint-disable
In [this PR](https://github.com/oppia/oppia/pull/5582/files#diff-47320e1c0a2e765ffd35d070966fd6e0R129), the author uses the construct `# pylint: disable=W0212`. This is hard to understand and it would be better to use the human-readable name instead.

It would be nice if we could detect such messages ('disable=[A-Z][0-9]{4}') and request (via a lint check) that the developer either remove the necessity for the lint exclusion altogether, or else use the human-readable version of the error code (and give them some guidance on where to find this human-readable version).




Discussion:

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -202,6 +202,15 @@
             'core/tests/performance_framework/perf_domain.py'),
         'excluded_dirs': ('scripts/',)
     },
+    {
+        'regexp': r'# pylint:\s*disable=[A-Z][0-9]{4}',
+        'message': 'Please remove pylint exculsion if it is unnecessary or '
+                   'make it human readable with a sentence instead of an id. '
+                   'The id to message list can be seen '
+                   'here->http://pylint-messages.wikidot.com/all-codes',
+        'excluded_files': (),
+        'excluded_dirs': ()
+    },
     {
         'regexp': r'self.assertEquals\(',
         'message': "Please do not use self.assertEquals method. " +
@@ -1580,8 +1589,7 @@ def main():
         html_directive_name_messages + import_order_messages +
         newline_messages + docstring_messages + comment_messages +
         html_tag_and_attribute_messages + html_linter_messages +
-        linter_messages + pattern_messages +
-        copyright_notice_messages)
+        linter_messages + pattern_messages + copyright_notice_messages)
     if any([message.startswith(_MESSAGE_TYPE_FAILED) for message in
             all_messages]):
         sys.exit(1)


Test patch:
Repository: oppia/oppia

Issue:
Add check to match line breaks in controller dependencies
Line breaks between stringified dependencies and function parameters should match for each controller (See [here](https://github.com/oppia/oppia/pull/5659#discussion_r229619308)). A similar check was introduced in PR #5225.
To implement this check, the earlier used regexp can be extended further.


Discussion:

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -1294,7 +1294,7 @@ def _match_line_breaks_in_controller_dependencies(all_files):
 
     # For RegExp explanation, please see https://regex101.com/r/T85GWZ/2/.
     pattern_to_match = (
-        r'controller: \[(?P<stringfied_dependencies>[\S\s]*?)' +
+        r'controller.* \[(?P<stringfied_dependencies>[\S\s]*?)' +
         r'function\((?P<function_parameters>[\S\s]*?)\)')
     for filename in files_to_check:
         with open(filename) as f:


Test patch:
Repository: oppia/oppia

Issue:
JS and CSS lint errors get through the pre-commit linter without causing the build to fail
We had introduced the concept of `Error Summary` in PR #5748 wherein we put the JS and CSS lint errors in a `result` queue to print at the end here: https://github.com/oppia/oppia/blob/develop/scripts/pre_commit_linter.py#L483
Putting this statement above [this](https://github.com/oppia/oppia/blob/develop/scripts/pre_commit_linter.py#L485) seems to be causing some problem. This statement is not executed some times resulting in a passed build with errors (See https://travis-ci.org/oppia/oppia/jobs/457941369#L3091).
A possible fix would be to move the latter before the former, that is, failing the build as soon as we encounter an error.


Discussion:

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -726,7 +726,7 @@ def _pre_commit_linter(all_files):
     print '----------------------------------------'
 
     for process in linting_processes:
-        process.daemon = True
+        process.daemon = False
         process.start()
 
     for process in linting_processes:


Test patch:
Repository: oppia/oppia

Issue:
The video on the Fractions landing page is 404-ing.
See https://www.oppia.org/fractions?viewerType=teacher (and scroll down). The video link seems to be broken:

![screenshot from 2018-11-23 19-54-57](https://user-images.githubusercontent.com/10575562/48964324-c4f02380-ef59-11e8-95c0-e9e9cc37f58a.png)

I think this might be something to do with the build process, since it is working fine in develop. (To test the built version, use the --prod_env flag when running start.sh.)


Discussion:
/cc @nithusha21 @aks681 I think this is a blocking bug for the next release.

Resolving patch:
diff --git a/scripts/build.py b/scripts/build.py
--- a/scripts/build.py
+++ b/scripts/build.py
@@ -87,7 +87,7 @@
 # Hashes for files with these paths should be provided to the frontend in
 # JS hashes object.
 FILEPATHS_PROVIDED_TO_FRONTEND = (
-    'images/*', 'i18n/*', '*_directive.html', '*.png', '*.json')
+    'images/*', 'videos/*', 'i18n/*', '*_directive.html', '*.png', '*.json')
 
 HASH_BLOCK_SIZE = 2**20
 


Test patch:
Repository: oppia/oppia

Issue:
Introduce Improvements Tab to Exploration Editor
![improvements-tab](https://user-images.githubusercontent.com/5094060/47670584-eee53e80-db83-11e8-8cf2-c21123ba28f7.jpg)

The design borrows heavily from the Creator Dashboard, so there is a lot of opportunity for code re-use.

**Requirements**:
- HTML template rendered by bare-bones directive.
  - No need for any cards, just a containing div for them.
- Must be backed by a config property flag — it is only visible in editor page when the flag is turned on.


Discussion:

Resolving patch:
diff --git a/core/controllers/editor.py b/core/controllers/editor.py
--- a/core/controllers/editor.py
+++ b/core/controllers/editor.py
@@ -878,3 +878,17 @@ def get(self, exploration_id):
         self.render_json({
             'unresolved_answers': unresolved_answers_with_frequency
         })
+
+
+class ExplorationFeaturesHandler(EditorHandler):
+    """Returns features the given exploration is configured to support."""
+
+    GET_HANDLER_ERROR_RETURN_TYPE = feconf.HANDLER_TYPE_JSON
+
+    @acl_decorators.can_play_exploration
+    def get(self, unused_exploration_id):
+        """Handles GET requests for an exploration's features."""
+        self.render_json({
+            'is_improvements_tab_enabled':
+                config_domain.IS_IMPROVEMENTS_TAB_ENABLED.value,
+        })
diff --git a/core/domain/config_domain.py b/core/domain/config_domain.py
--- a/core/domain/config_domain.py
+++ b/core/domain/config_domain.py
@@ -274,3 +274,8 @@ def get_config_property_schemas(cls):
 RECORD_PLAYTHROUGH_PROBABILITY = ConfigProperty(
     'record_playthrough_probability', FLOAT_SCHEMA,
     'The probability of recording playthroughs', 0.2)
+
+IS_IMPROVEMENTS_TAB_ENABLED = ConfigProperty(
+    'is_improvements_tab_enabled', BOOL_SCHEMA,
+    'Exposes the Improvements Tab for creators in the exploration editor.',
+    False)
diff --git a/main.py b/main.py
--- a/main.py
+++ b/main.py
@@ -352,6 +352,9 @@ def ui_access_wrapper(self, *args, **kwargs):
     get_redirect_route(
         r'/moderatorhandler/email_draft', moderator.EmailDraftHandler),
 
+    get_redirect_route(
+        r'/explorehandler/features/<exploration_id>',
+        editor.ExplorationFeaturesHandler),
     get_redirect_route(
         r'%s/<exploration_id>' % feconf.EXPLORATION_URL_PREFIX,
         reader.ExplorationPage),


Test patch:
Repository: oppia/oppia

Issue:
Improve error message for pre-submit checks
_This is an issue to keep track of all the confusing pre-submit error messages which developers have a hard time understanding, and then improve them._

The error messages of the following checks need to be improved:

1.  `_match_line_breaks_in_controller_dependencies(..)`: [Done in PR #6246]
      This function checks whether the line breaks between the dependencies
    listed in the controller of a directive or service exactly match those
    between the arguments of the controller function.


Discussion:
Hi @apb7, also there are many functions which check only js files/py files. Hence there description should include that also. What do you suggest?
![screenshot from 2019-02-09 02-54-21](https://user-images.githubusercontent.com/30555544/52506764-9824e180-2c15-11e9-916d-cf946103d872.png)
Like this function checks py files, hence its function should include this.
Like we can add ```This function ensures that comments follow the correct style in python files```
@YashJipkate @lilithxxx Any suggestions here ?
@anubhavsinha98 Yes there are some functions with an incomplete description in their docstrings. But do those concern this issue? I think this issue keeps track of the error messages shown when a check fails.
However, since you pointed that out, it would be great if you improve the docstrings as well since it is also a part of developer experience :)
Thanks!

@YashJipkate Thanks!

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -1495,10 +1495,11 @@ def _match_line_breaks_in_controller_dependencies(all_files):
                 if stringfied_dependencies != function_parameters:
                     failed = True
                     print (
-                        '%s --> Please ensure that line breaks between '
-                        'the stringfied dependencies: "%s" and the function '
-                        'parameters: "%s" for the corresponding controller '
-                        'in this file exactly match.' % (
+                        'Please ensure that in file %s the line breaks pattern '
+                        'between the dependencies mentioned as strings:\n[%s]\n'
+                        'and the dependencies mentioned as function parameters:'
+                        '\n(%s)\nfor the corresponding controller should '
+                        'exactly match.' % (
                             filename, stringfied_dependencies,
                             function_parameters))
                     print ''


Test patch: