{"action":"created","comment":{"url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls/comments/226581041","pull_request_review_id":166423413,"id":226581041,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNjU4MTA0MQ==","diff_hunk":"@@ -0,0 +1,149 @@\n+const compareLangKeys = () => {\n+  // lib is needed to show deuplicated keys\n+  const jsonValidator = require('json-dup-key-validator');\n+\n+  //requiring path and fs modules\n+  const path = require('path');\n+  const fs = require('fs');\n+  const directoryPath = path.join(__dirname, 'locales');\n+\n+  const mapAllFiles = (files, filesContent) => {\n+    const isJsonFile = (JSONdata, file) => {\n+      const singleFilesContent = [];\n+\n+      for (const key in JSONdata) {\n+        singleFilesContent.push(key);\n+      }\n+      filesContent.push({\n+        fileName: file,\n+        fileKeys: singleFilesContent\n+      });\n+    };\n+\n+    const isNotJsonFile = () => {\n+      notJSON++;\n+      filesContent.push({\n+        fileName: 'null',\n+        fileKeys: []\n+      });\n+    };\n+\n+    const loadFiles = (file, isJsonFile, isNotJsonFile) => {\n+      // load file if it is a JSON\n+      if (file.includes('.json')) {\n+        const JSONdata = require(`./locales/${file}`);\n+\n+        const isDuplicated = new Promise((resolve, reject) => {\n+          fs.readFile(`./locales/${file}`, 'utf8', (err, data) => {\n+            if (err) {\n+              reject(err);\n+            } else {\n+              const validateDuplicates = jsonValidator.validate(data, false);\n+              if (validateDuplicates) {\n+                resolve(\n+                  `[DUPLICATED] ${jsonValidator.validate(\n+                    data,\n+                    false\n+                  )} => in ${file}`\n+                );\n+              }\n+            }\n+          });\n+        });\n+        isDuplicated.then(res => {\n+          console.info(res);\n+        });\n+        isDuplicated.catch(rej => {\n+          console.info(rej);\n+        });\n+\n+        isJsonFile(JSONdata, file);\n+      } else {\n+        isNotJsonFile;\n+      }\n+    };\n+\n+    files.forEach(file => {\n+      loadFiles(file, isJsonFile, isNotJsonFile);\n+    });\n+  };\n+  const countKeysBetweenFiles = filesContent => {\n+    const singleFinalKeysArr = [];\n+    for (const key in filesContent) {\n+      const filesContentKeys = filesContent[key]['fileKeys'];\n+      for (const k in filesContentKeys) {\n+        singleFinalKeysArr.push(filesContentKeys[k]);\n+      }\n+    }\n+    const map = singleFinalKeysArr.reduce((prev, cur) => {\n+      prev[cur] = (prev[cur] || 0) + 1;\n+      return prev;\n+    }, {});\n+\n+    return map;\n+  };\n+\n+  const countNotJsonFiles = files => {\n+    let nonJson = 0;\n+    files.forEach(f => {\n+      if (!f.includes('.json')) {\n+        nonJson++;\n+      }\n+    });\n+    return nonJson;\n+  };\n+\n+  const dspFinalResults = (finalCountedKeys, jsonFiles, filesContent) => {\n+    for (const key in finalCountedKeys) {\n+      // console.log(notJSON)\n+      if (finalCountedKeys[key] < jsonFiles) {\n+        const bad_val = `[BAD] ${key}`;\n+\n+        for (const k in filesContent) {\n+          // in case Key not seen\n+\n+          const filesContentKeys = filesContent[k]['fileKeys'];\n+          const fileNameFromK = filesContent[k];\n+          const { fileName } = fileNameFromK;\n+          if (\n+            filesContentKeys.length !== 0 &&\n+            !filesContentKeys.includes(key)\n+          ) {\n+            console.info(`${bad_val} => not seen in ${fileName}`);\n+          }\n+          for (const n in filesContentKeys) {","path":"index.js","position":114,"original_position":114,"commit_id":"30810daf0379f319a3cade684babfcc674780de6","original_commit_id":"30810daf0379f319a3cade684babfcc674780de6","user":{"login":"Ciunkos","id":1042119,"node_id":"MDQ6VXNlcjEwNDIxMTk=","avatar_url":"https://avatars2.githubusercontent.com/u/1042119?v=4","gravatar_id":"","url":"https://api.github.com/users/Ciunkos","html_url":"https://github.com/Ciunkos","followers_url":"https://api.github.com/users/Ciunkos/followers","following_url":"https://api.github.com/users/Ciunkos/following{/other_user}","gists_url":"https://api.github.com/users/Ciunkos/gists{/gist_id}","starred_url":"https://api.github.com/users/Ciunkos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ciunkos/subscriptions","organizations_url":"https://api.github.com/users/Ciunkos/orgs","repos_url":"https://api.github.com/users/Ciunkos/repos","events_url":"https://api.github.com/users/Ciunkos/events{/privacy}","received_events_url":"https://api.github.com/users/Ciunkos/received_events","type":"User","site_admin":false},"body":"Please use more meaningful names for variables, for example `fileKey` would fit better here.","created_at":"2018-10-19T09:11:21Z","updated_at":"2018-10-19T09:16:44Z","html_url":"https://github.com/sandstreamdev/json-locales-checker/pull/1#discussion_r226581041","pull_request_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls/comments/226581041"},"html":{"href":"https://github.com/sandstreamdev/json-locales-checker/pull/1#discussion_r226581041"},"pull_request":{"href":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls/1","id":223918104,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzOTE4MTA0","html_url":"https://github.com/sandstreamdev/json-locales-checker/pull/1","diff_url":"https://github.com/sandstreamdev/json-locales-checker/pull/1.diff","patch_url":"https://github.com/sandstreamdev/json-locales-checker/pull/1.patch","issue_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/issues/1","number":1,"state":"open","locked":false,"title":"Initial commit","user":{"login":"kendyl93","id":34007033,"node_id":"MDQ6VXNlcjM0MDA3MDMz","avatar_url":"https://avatars1.githubusercontent.com/u/34007033?v=4","gravatar_id":"","url":"https://api.github.com/users/kendyl93","html_url":"https://github.com/kendyl93","followers_url":"https://api.github.com/users/kendyl93/followers","following_url":"https://api.github.com/users/kendyl93/following{/other_user}","gists_url":"https://api.github.com/users/kendyl93/gists{/gist_id}","starred_url":"https://api.github.com/users/kendyl93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kendyl93/subscriptions","organizations_url":"https://api.github.com/users/kendyl93/orgs","repos_url":"https://api.github.com/users/kendyl93/repos","events_url":"https://api.github.com/users/kendyl93/events{/privacy}","received_events_url":"https://api.github.com/users/kendyl93/received_events","type":"User","site_admin":false},"body":"Basic implementation of Json Locales Checker.\r\n\r\nIt compares the keys in JSON files in _/locales_ directory and message will be shown in console in case of:\r\n\r\n1. Duplicate keys\r\n2. Missing keys\r\n3. Wrong keys names\r\n\r\n\r\n","created_at":"2018-10-18T11:20:04Z","updated_at":"2018-10-19T09:16:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7497e9ccb64a20f283a721a21be2d27cded8a416","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls/1/commits","review_comments_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls/1/comments","review_comment_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/issues/1/comments","statuses_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/statuses/30810daf0379f319a3cade684babfcc674780de6","head":{"label":"sandstreamdev:initial_implementation","ref":"initial_implementation","sha":"30810daf0379f319a3cade684babfcc674780de6","user":{"login":"sandstreamdev","id":44231525,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MjMxNTI1","avatar_url":"https://avatars3.githubusercontent.com/u/44231525?v=4","gravatar_id":"","url":"https://api.github.com/users/sandstreamdev","html_url":"https://github.com/sandstreamdev","followers_url":"https://api.github.com/users/sandstreamdev/followers","following_url":"https://api.github.com/users/sandstreamdev/following{/other_user}","gists_url":"https://api.github.com/users/sandstreamdev/gists{/gist_id}","starred_url":"https://api.github.com/users/sandstreamdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandstreamdev/subscriptions","organizations_url":"https://api.github.com/users/sandstreamdev/orgs","repos_url":"https://api.github.com/users/sandstreamdev/repos","events_url":"https://api.github.com/users/sandstreamdev/events{/privacy}","received_events_url":"https://api.github.com/users/sandstreamdev/received_events","type":"Organization","site_admin":false},"repo":{"id":153449407,"node_id":"MDEwOlJlcG9zaXRvcnkxNTM0NDk0MDc=","name":"json-locales-checker","full_name":"sandstreamdev/json-locales-checker","private":false,"owner":{"login":"sandstreamdev","id":44231525,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MjMxNTI1","avatar_url":"https://avatars3.githubusercontent.com/u/44231525?v=4","gravatar_id":"","url":"https://api.github.com/users/sandstreamdev","html_url":"https://github.com/sandstreamdev","followers_url":"https://api.github.com/users/sandstreamdev/followers","following_url":"https://api.github.com/users/sandstreamdev/following{/other_user}","gists_url":"https://api.github.com/users/sandstreamdev/gists{/gist_id}","starred_url":"https://api.github.com/users/sandstreamdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandstreamdev/subscriptions","organizations_url":"https://api.github.com/users/sandstreamdev/orgs","repos_url":"https://api.github.com/users/sandstreamdev/repos","events_url":"https://api.github.com/users/sandstreamdev/events{/privacy}","received_events_url":"https://api.github.com/users/sandstreamdev/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/sandstreamdev/json-locales-checker","description":null,"fork":false,"url":"https://api.github.com/repos/sandstreamdev/json-locales-checker","forks_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/forks","keys_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/teams","hooks_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/hooks","issue_events_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/issues/events{/number}","events_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/events","assignees_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/assignees{/user}","branches_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/branches{/branch}","tags_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/tags","blobs_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/git/refs{/sha}","trees_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/statuses/{sha}","languages_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/languages","stargazers_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/stargazers","contributors_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/contributors","subscribers_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/subscribers","subscription_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/subscription","commits_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/commits{/sha}","git_commits_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/git/commits{/sha}","comments_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/comments{/number}","issue_comment_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/issues/comments{/number}","contents_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/contents/{+path}","compare_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/merges","archive_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/downloads","issues_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/issues{/number}","pulls_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls{/number}","milestones_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/milestones{/number}","notifications_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/labels{/name}","releases_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/releases{/id}","deployments_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/deployments","created_at":"2018-10-17T12:00:26Z","updated_at":"2018-10-17T12:00:29Z","pushed_at":"2018-10-18T11:20:04Z","git_url":"git://github.com/sandstreamdev/json-locales-checker.git","ssh_url":"git@github.com:sandstreamdev/json-locales-checker.git","clone_url":"https://github.com/sandstreamdev/json-locales-checker.git","svn_url":"https://github.com/sandstreamdev/json-locales-checker","homepage":null,"size":4,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"sandstreamdev:master","ref":"master","sha":"6a7ff4c79fa2a1f8406b522bcf675366f7ff9f72","user":{"login":"sandstreamdev","id":44231525,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MjMxNTI1","avatar_url":"https://avatars3.githubusercontent.com/u/44231525?v=4","gravatar_id":"","url":"https://api.github.com/users/sandstreamdev","html_url":"https://github.com/sandstreamdev","followers_url":"https://api.github.com/users/sandstreamdev/followers","following_url":"https://api.github.com/users/sandstreamdev/following{/other_user}","gists_url":"https://api.github.com/users/sandstreamdev/gists{/gist_id}","starred_url":"https://api.github.com/users/sandstreamdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandstreamdev/subscriptions","organizations_url":"https://api.github.com/users/sandstreamdev/orgs","repos_url":"https://api.github.com/users/sandstreamdev/repos","events_url":"https://api.github.com/users/sandstreamdev/events{/privacy}","received_events_url":"https://api.github.com/users/sandstreamdev/received_events","type":"Organization","site_admin":false},"repo":{"id":153449407,"node_id":"MDEwOlJlcG9zaXRvcnkxNTM0NDk0MDc=","name":"json-locales-checker","full_name":"sandstreamdev/json-locales-checker","private":false,"owner":{"login":"sandstreamdev","id":44231525,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MjMxNTI1","avatar_url":"https://avatars3.githubusercontent.com/u/44231525?v=4","gravatar_id":"","url":"https://api.github.com/users/sandstreamdev","html_url":"https://github.com/sandstreamdev","followers_url":"https://api.github.com/users/sandstreamdev/followers","following_url":"https://api.github.com/users/sandstreamdev/following{/other_user}","gists_url":"https://api.github.com/users/sandstreamdev/gists{/gist_id}","starred_url":"https://api.github.com/users/sandstreamdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandstreamdev/subscriptions","organizations_url":"https://api.github.com/users/sandstreamdev/orgs","repos_url":"https://api.github.com/users/sandstreamdev/repos","events_url":"https://api.github.com/users/sandstreamdev/events{/privacy}","received_events_url":"https://api.github.com/users/sandstreamdev/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/sandstreamdev/json-locales-checker","description":null,"fork":false,"url":"https://api.github.com/repos/sandstreamdev/json-locales-checker","forks_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/forks","keys_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/teams","hooks_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/hooks","issue_events_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/issues/events{/number}","events_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/events","assignees_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/assignees{/user}","branches_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/branches{/branch}","tags_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/tags","blobs_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/git/refs{/sha}","trees_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/statuses/{sha}","languages_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/languages","stargazers_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/stargazers","contributors_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/contributors","subscribers_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/subscribers","subscription_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/subscription","commits_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/commits{/sha}","git_commits_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/git/commits{/sha}","comments_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/comments{/number}","issue_comment_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/issues/comments{/number}","contents_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/contents/{+path}","compare_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/merges","archive_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/downloads","issues_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/issues{/number}","pulls_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls{/number}","milestones_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/milestones{/number}","notifications_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/labels{/name}","releases_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/releases{/id}","deployments_url":"https://api.github.com/repos/sandstreamdev/json-locales-checker/deployments","created_at":"2018-10-17T12:00:26Z","updated_at":"2018-10-17T12:00:29Z","pushed_at":"2018-10-18T11:20:04Z","git_url":"git://github.com/sandstreamdev/json-locales-checker.git","ssh_url":"git@github.com:sandstreamdev/json-locales-checker.git","clone_url":"https://github.com/sandstreamdev/json-locales-checker.git","svn_url":"https://github.com/sandstreamdev/json-locales-checker","homepage":null,"size":4,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls/1"},"html":{"href":"https://github.com/sandstreamdev/json-locales-checker/pull/1"},"issue":{"href":"https://api.github.com/repos/sandstreamdev/json-locales-checker/issues/1"},"comments":{"href":"https://api.github.com/repos/sandstreamdev/json-locales-checker/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sandstreamdev/json-locales-checker/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/sandstreamdev/json-locales-checker/statuses/30810daf0379f319a3cade684babfcc674780de6"}},"author_association":"NONE"}}
{"actor":{"display_login":"Ciunkos"}}