{"action":"created","comment":{"url":"https://api.github.com/repos/coala/coala-bears/pulls/comments/86066270","pull_request_review_id":6740557,"id":86066270,"diff_hunk":"@@ -0,0 +1,147 @@\n+import unittest\n+from queue import Queue\n+from coalib.settings.Section import Section\n+from bears.jinja2.Jinja2Bear import Jinja2Bear\n+from tests.LocalBearTestHelper import verify_local_bear, execute_bear\n+\n+\n+Jinja2BearVariableSpacingTest = verify_local_bear(\n+    Jinja2Bear,\n+    valid_files=(r\"foo {{ var }}\",),\n+    invalid_files=(r\"foo {{var }}\",\n+                   r\"foo {{ var}} bar\",\n+                   r\"{{  var }}\",\n+                   r\"{{ good_var }} foo {{bad_var }}\"))\n+\n+Jinja2BearCustomVariableSpacingTest = verify_local_bear(\n+    Jinja2Bear,\n+    valid_files=(r\"foo {{var}}\",),\n+    invalid_files=(r\"foo {{ var }}\",\n+                   r\"foo {{ var}} bar\",\n+                   r\"{{  var }}\"),\n+    settings={\"variable_spacing\": \"0\"})\n+\n+\n+class Jinja2BearSpacingDiffTest(unittest.TestCase):\n+\n+    def setUp(self):\n+        self.section = Section(\"\")\n+        self.uut = Jinja2Bear(self.section, Queue())","path":"tests/jinja2/Jinja2BearTest.py","position":29,"original_position":29,"commit_id":"48573e094cc435e14ed5b20ca3e61b2ef3cd523e","original_commit_id":"48573e094cc435e14ed5b20ca3e61b2ef3cd523e","user":{"login":"AbdealiJK","id":2200743,"avatar_url":"https://avatars.githubusercontent.com/u/2200743?v=3","gravatar_id":"","url":"https://api.github.com/users/AbdealiJK","html_url":"https://github.com/AbdealiJK","followers_url":"https://api.github.com/users/AbdealiJK/followers","following_url":"https://api.github.com/users/AbdealiJK/following{/other_user}","gists_url":"https://api.github.com/users/AbdealiJK/gists{/gist_id}","starred_url":"https://api.github.com/users/AbdealiJK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AbdealiJK/subscriptions","organizations_url":"https://api.github.com/users/AbdealiJK/orgs","repos_url":"https://api.github.com/users/AbdealiJK/repos","events_url":"https://api.github.com/users/AbdealiJK/events{/privacy}","received_events_url":"https://api.github.com/users/AbdealiJK/received_events","type":"User","site_admin":false},"body":"`self.uut = Jinja2Bear(Section(), Queue())` as section isnt really being used","created_at":"2016-11-02T03:00:50Z","updated_at":"2016-11-02T03:02:43Z","html_url":"https://github.com/coala/coala-bears/pull/969#discussion_r86066270","pull_request_url":"https://api.github.com/repos/coala/coala-bears/pulls/969","_links":{"self":{"href":"https://api.github.com/repos/coala/coala-bears/pulls/comments/86066270"},"html":{"href":"https://github.com/coala/coala-bears/pull/969#discussion_r86066270"},"pull_request":{"href":"https://api.github.com/repos/coala/coala-bears/pulls/969"}}},"pull_request":{"url":"https://api.github.com/repos/coala/coala-bears/pulls/969","id":91788634,"html_url":"https://github.com/coala/coala-bears/pull/969","diff_url":"https://github.com/coala/coala-bears/pull/969.diff","patch_url":"https://github.com/coala/coala-bears/pull/969.patch","issue_url":"https://api.github.com/repos/coala/coala-bears/issues/969","number":969,"state":"open","locked":false,"title":"New Bear: Jinja2Bear","user":{"login":"NiklasMM","id":1924002,"avatar_url":"https://avatars.githubusercontent.com/u/1924002?v=3","gravatar_id":"","url":"https://api.github.com/users/NiklasMM","html_url":"https://github.com/NiklasMM","followers_url":"https://api.github.com/users/NiklasMM/followers","following_url":"https://api.github.com/users/NiklasMM/following{/other_user}","gists_url":"https://api.github.com/users/NiklasMM/gists{/gist_id}","starred_url":"https://api.github.com/users/NiklasMM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NiklasMM/subscriptions","organizations_url":"https://api.github.com/users/NiklasMM/orgs","repos_url":"https://api.github.com/users/NiklasMM/repos","events_url":"https://api.github.com/users/NiklasMM/events{/privacy}","received_events_url":"https://api.github.com/users/NiklasMM/received_events","type":"User","site_admin":false},"body":"This Bear is a native Bear which processes [Jinja2](http://jinja.pocoo.org/docs/dev/) template files.\r\n\r\nThere is no real global style guide for Jinja2. The one by the [Chromium Project](https://www.chromium.org/developers/jinja), which I referenced in the proposal, turned out to be ~~crap~~ suboptimal, because in many cases it collides with the official documentation and as a heavy user of Jinja2 I just don't like it.\r\n\r\nSo I chose the defaults of this Bear by looking at the official documentation, my own code and other sources on the Web, I also made it configurable, so that even the Chromium folks could still use it.\r\n\r\nThe bear can now detect:\r\n\r\n* **Unmatched opening or closing control blocks:**  In Jinja2 each `if` and `for` construct must be matched by a corresponding closing tag. If this is not the case this is a syntax error and the file can't be processed.\r\n\r\nThe bear can detect and fix:\r\n\r\n* **Variable and control tag spacing issues**: Variables `{{ var_name }}` and control tags `{% for x in y %}` should be padded with a space on each side for better readability. This is both detected and can be automatically fixed by the Bear. The number of spaces can be changed via settings.\r\n\r\n* **Missing/Wrong control end labels** Since there can be much code in between the beginning and end of a control block, it can be hard to know which for-loop of if-block is being closed, when encountering an `{% endfor %}` or `{% endif %}` tag, especially when many of them are nested. Therefore it is good practice to add a comment indicating which block is closed, which is equal to the start tag, e.g.: `{% endfor %}{# for x in y #}`. Missing and differing control end labels can be detected and automatically fixed by the Bear.\r\n\r\nThis is AFAIK the only linter for Jinja2. There is a couple of more things that it could be checking for, but I think this is already a good set of features. I have already tried it out on some of my templates from work and found it very useful.\r\n\r\n*Please review carefully, as this is my first Bear!*\r\n\r\nCloses https://github.com/coala/coala-bears/issues/959","created_at":"2016-11-01T14:05:22Z","updated_at":"2016-11-02T03:02:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"db640eb14d58f18cc5bb7a21556dc22ebe0e8eed","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/coala/coala-bears/pulls/969/commits","review_comments_url":"https://api.github.com/repos/coala/coala-bears/pulls/969/comments","review_comment_url":"https://api.github.com/repos/coala/coala-bears/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coala/coala-bears/issues/969/comments","statuses_url":"https://api.github.com/repos/coala/coala-bears/statuses/48573e094cc435e14ed5b20ca3e61b2ef3cd523e","head":{"label":"NiklasMM:feat/959_jinja2-bear","ref":"feat/959_jinja2-bear","sha":"48573e094cc435e14ed5b20ca3e61b2ef3cd523e","user":{"login":"NiklasMM","id":1924002,"avatar_url":"https://avatars.githubusercontent.com/u/1924002?v=3","gravatar_id":"","url":"https://api.github.com/users/NiklasMM","html_url":"https://github.com/NiklasMM","followers_url":"https://api.github.com/users/NiklasMM/followers","following_url":"https://api.github.com/users/NiklasMM/following{/other_user}","gists_url":"https://api.github.com/users/NiklasMM/gists{/gist_id}","starred_url":"https://api.github.com/users/NiklasMM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NiklasMM/subscriptions","organizations_url":"https://api.github.com/users/NiklasMM/orgs","repos_url":"https://api.github.com/users/NiklasMM/repos","events_url":"https://api.github.com/users/NiklasMM/events{/privacy}","received_events_url":"https://api.github.com/users/NiklasMM/received_events","type":"User","site_admin":false},"repo":{"id":72208874,"name":"coala-bears","full_name":"NiklasMM/coala-bears","owner":{"login":"NiklasMM","id":1924002,"avatar_url":"https://avatars.githubusercontent.com/u/1924002?v=3","gravatar_id":"","url":"https://api.github.com/users/NiklasMM","html_url":"https://github.com/NiklasMM","followers_url":"https://api.github.com/users/NiklasMM/followers","following_url":"https://api.github.com/users/NiklasMM/following{/other_user}","gists_url":"https://api.github.com/users/NiklasMM/gists{/gist_id}","starred_url":"https://api.github.com/users/NiklasMM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NiklasMM/subscriptions","organizations_url":"https://api.github.com/users/NiklasMM/orgs","repos_url":"https://api.github.com/users/NiklasMM/repos","events_url":"https://api.github.com/users/NiklasMM/events{/privacy}","received_events_url":"https://api.github.com/users/NiklasMM/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NiklasMM/coala-bears","description":"Bears for coala","fork":true,"url":"https://api.github.com/repos/NiklasMM/coala-bears","forks_url":"https://api.github.com/repos/NiklasMM/coala-bears/forks","keys_url":"https://api.github.com/repos/NiklasMM/coala-bears/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NiklasMM/coala-bears/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NiklasMM/coala-bears/teams","hooks_url":"https://api.github.com/repos/NiklasMM/coala-bears/hooks","issue_events_url":"https://api.github.com/repos/NiklasMM/coala-bears/issues/events{/number}","events_url":"https://api.github.com/repos/NiklasMM/coala-bears/events","assignees_url":"https://api.github.com/repos/NiklasMM/coala-bears/assignees{/user}","branches_url":"https://api.github.com/repos/NiklasMM/coala-bears/branches{/branch}","tags_url":"https://api.github.com/repos/NiklasMM/coala-bears/tags","blobs_url":"https://api.github.com/repos/NiklasMM/coala-bears/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NiklasMM/coala-bears/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NiklasMM/coala-bears/git/refs{/sha}","trees_url":"https://api.github.com/repos/NiklasMM/coala-bears/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NiklasMM/coala-bears/statuses/{sha}","languages_url":"https://api.github.com/repos/NiklasMM/coala-bears/languages","stargazers_url":"https://api.github.com/repos/NiklasMM/coala-bears/stargazers","contributors_url":"https://api.github.com/repos/NiklasMM/coala-bears/contributors","subscribers_url":"https://api.github.com/repos/NiklasMM/coala-bears/subscribers","subscription_url":"https://api.github.com/repos/NiklasMM/coala-bears/subscription","commits_url":"https://api.github.com/repos/NiklasMM/coala-bears/commits{/sha}","git_commits_url":"https://api.github.com/repos/NiklasMM/coala-bears/git/commits{/sha}","comments_url":"https://api.github.com/repos/NiklasMM/coala-bears/comments{/number}","issue_comment_url":"https://api.github.com/repos/NiklasMM/coala-bears/issues/comments{/number}","contents_url":"https://api.github.com/repos/NiklasMM/coala-bears/contents/{+path}","compare_url":"https://api.github.com/repos/NiklasMM/coala-bears/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NiklasMM/coala-bears/merges","archive_url":"https://api.github.com/repos/NiklasMM/coala-bears/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NiklasMM/coala-bears/downloads","issues_url":"https://api.github.com/repos/NiklasMM/coala-bears/issues{/number}","pulls_url":"https://api.github.com/repos/NiklasMM/coala-bears/pulls{/number}","milestones_url":"https://api.github.com/repos/NiklasMM/coala-bears/milestones{/number}","notifications_url":"https://api.github.com/repos/NiklasMM/coala-bears/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NiklasMM/coala-bears/labels{/name}","releases_url":"https://api.github.com/repos/NiklasMM/coala-bears/releases{/id}","deployments_url":"https://api.github.com/repos/NiklasMM/coala-bears/deployments","created_at":"2016-10-28T13:17:16Z","updated_at":"2016-10-28T13:17:17Z","pushed_at":"2016-11-01T15:03:12Z","git_url":"git://github.com/NiklasMM/coala-bears.git","ssh_url":"git@github.com:NiklasMM/coala-bears.git","clone_url":"https://github.com/NiklasMM/coala-bears.git","svn_url":"https://github.com/NiklasMM/coala-bears","homepage":"https://coala.io/","size":1142,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"coala:master","ref":"master","sha":"a404eba455b595eb8bb198ad1f1b96381e2c7e39","user":{"login":"coala","id":10620750,"avatar_url":"https://avatars.githubusercontent.com/u/10620750?v=3","gravatar_id":"","url":"https://api.github.com/users/coala","html_url":"https://github.com/coala","followers_url":"https://api.github.com/users/coala/followers","following_url":"https://api.github.com/users/coala/following{/other_user}","gists_url":"https://api.github.com/users/coala/gists{/gist_id}","starred_url":"https://api.github.com/users/coala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coala/subscriptions","organizations_url":"https://api.github.com/users/coala/orgs","repos_url":"https://api.github.com/users/coala/repos","events_url":"https://api.github.com/users/coala/events{/privacy}","received_events_url":"https://api.github.com/users/coala/received_events","type":"Organization","site_admin":false},"repo":{"id":51688289,"name":"coala-bears","full_name":"coala/coala-bears","owner":{"login":"coala","id":10620750,"avatar_url":"https://avatars.githubusercontent.com/u/10620750?v=3","gravatar_id":"","url":"https://api.github.com/users/coala","html_url":"https://github.com/coala","followers_url":"https://api.github.com/users/coala/followers","following_url":"https://api.github.com/users/coala/following{/other_user}","gists_url":"https://api.github.com/users/coala/gists{/gist_id}","starred_url":"https://api.github.com/users/coala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coala/subscriptions","organizations_url":"https://api.github.com/users/coala/orgs","repos_url":"https://api.github.com/users/coala/repos","events_url":"https://api.github.com/users/coala/events{/privacy}","received_events_url":"https://api.github.com/users/coala/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coala/coala-bears","description":"Bears for coala","fork":false,"url":"https://api.github.com/repos/coala/coala-bears","forks_url":"https://api.github.com/repos/coala/coala-bears/forks","keys_url":"https://api.github.com/repos/coala/coala-bears/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coala/coala-bears/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coala/coala-bears/teams","hooks_url":"https://api.github.com/repos/coala/coala-bears/hooks","issue_events_url":"https://api.github.com/repos/coala/coala-bears/issues/events{/number}","events_url":"https://api.github.com/repos/coala/coala-bears/events","assignees_url":"https://api.github.com/repos/coala/coala-bears/assignees{/user}","branches_url":"https://api.github.com/repos/coala/coala-bears/branches{/branch}","tags_url":"https://api.github.com/repos/coala/coala-bears/tags","blobs_url":"https://api.github.com/repos/coala/coala-bears/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coala/coala-bears/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coala/coala-bears/git/refs{/sha}","trees_url":"https://api.github.com/repos/coala/coala-bears/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coala/coala-bears/statuses/{sha}","languages_url":"https://api.github.com/repos/coala/coala-bears/languages","stargazers_url":"https://api.github.com/repos/coala/coala-bears/stargazers","contributors_url":"https://api.github.com/repos/coala/coala-bears/contributors","subscribers_url":"https://api.github.com/repos/coala/coala-bears/subscribers","subscription_url":"https://api.github.com/repos/coala/coala-bears/subscription","commits_url":"https://api.github.com/repos/coala/coala-bears/commits{/sha}","git_commits_url":"https://api.github.com/repos/coala/coala-bears/git/commits{/sha}","comments_url":"https://api.github.com/repos/coala/coala-bears/comments{/number}","issue_comment_url":"https://api.github.com/repos/coala/coala-bears/issues/comments{/number}","contents_url":"https://api.github.com/repos/coala/coala-bears/contents/{+path}","compare_url":"https://api.github.com/repos/coala/coala-bears/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coala/coala-bears/merges","archive_url":"https://api.github.com/repos/coala/coala-bears/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coala/coala-bears/downloads","issues_url":"https://api.github.com/repos/coala/coala-bears/issues{/number}","pulls_url":"https://api.github.com/repos/coala/coala-bears/pulls{/number}","milestones_url":"https://api.github.com/repos/coala/coala-bears/milestones{/number}","notifications_url":"https://api.github.com/repos/coala/coala-bears/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coala/coala-bears/labels{/name}","releases_url":"https://api.github.com/repos/coala/coala-bears/releases{/id}","deployments_url":"https://api.github.com/repos/coala/coala-bears/deployments","created_at":"2016-02-14T09:25:11Z","updated_at":"2016-10-30T14:17:48Z","pushed_at":"2016-11-02T00:27:34Z","git_url":"git://github.com/coala/coala-bears.git","ssh_url":"git@github.com:coala/coala-bears.git","clone_url":"https://github.com/coala/coala-bears.git","svn_url":"https://github.com/coala/coala-bears","homepage":"https://coala.io/","size":9461,"stargazers_count":64,"watchers_count":64,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":132,"mirror_url":null,"open_issues_count":219,"forks":132,"open_issues":219,"watchers":64,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coala/coala-bears/pulls/969"},"html":{"href":"https://github.com/coala/coala-bears/pull/969"},"issue":{"href":"https://api.github.com/repos/coala/coala-bears/issues/969"},"comments":{"href":"https://api.github.com/repos/coala/coala-bears/issues/969/comments"},"review_comments":{"href":"https://api.github.com/repos/coala/coala-bears/pulls/969/comments"},"review_comment":{"href":"https://api.github.com/repos/coala/coala-bears/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coala/coala-bears/pulls/969/commits"},"statuses":{"href":"https://api.github.com/repos/coala/coala-bears/statuses/48573e094cc435e14ed5b20ca3e61b2ef3cd523e"}}}}
{"actor":{"display_login":"AbdealiJK"}}