diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e9bca96
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,17 @@
+*.class
+
+# Ignore everything in this directory
+target
+.classpath
+.settings
+.project
+*.iml
+*.iws
+*.ipr
+*.json
+.idea
+
+# Package Files #
+*.jar
+*.war
+*.ear
diff --git a/CodeQualityMatricesProject/.classpath b/CodeQualityMatricesProject/.classpath
deleted file mode 100644
index 9c865fb..0000000
--- a/CodeQualityMatricesProject/.classpath
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/CodeQualityMatricesProject/.gitignore b/CodeQualityMatricesProject/.gitignore
deleted file mode 100644
index b83d222..0000000
--- a/CodeQualityMatricesProject/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/CodeQualityMatricesProject/.idea/.name b/CodeQualityMatricesProject/.idea/.name
deleted file mode 100644
index f94cade..0000000
--- a/CodeQualityMatricesProject/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-CodeQualityMatrices
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/compiler.xml b/CodeQualityMatricesProject/.idea/compiler.xml
deleted file mode 100644
index 838d49b..0000000
--- a/CodeQualityMatricesProject/.idea/compiler.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/encodings.xml b/CodeQualityMatricesProject/.idea/encodings.xml
deleted file mode 100644
index b26911b..0000000
--- a/CodeQualityMatricesProject/.idea/encodings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml b/CodeQualityMatricesProject/.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml
deleted file mode 100644
index f3f3738..0000000
--- a/CodeQualityMatricesProject/.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/libraries/Maven__commons_codec_commons_codec_1_9.xml b/CodeQualityMatricesProject/.idea/libraries/Maven__commons_codec_commons_codec_1_9.xml
deleted file mode 100644
index a66d039..0000000
--- a/CodeQualityMatricesProject/.idea/libraries/Maven__commons_codec_commons_codec_1_9.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml b/CodeQualityMatricesProject/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml
deleted file mode 100644
index eab40b3..0000000
--- a/CodeQualityMatricesProject/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/libraries/Maven__junit_junit_3_8_1.xml b/CodeQualityMatricesProject/.idea/libraries/Maven__junit_junit_3_8_1.xml
deleted file mode 100644
index 71b2993..0000000
--- a/CodeQualityMatricesProject/.idea/libraries/Maven__junit_junit_3_8_1.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_5.xml b/CodeQualityMatricesProject/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_5.xml
deleted file mode 100644
index 666266c..0000000
--- a/CodeQualityMatricesProject/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_5.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_5_2.xml b/CodeQualityMatricesProject/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_5_2.xml
deleted file mode 100644
index fdb7ead..0000000
--- a/CodeQualityMatricesProject/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_5_2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_4_4.xml b/CodeQualityMatricesProject/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_4_4.xml
deleted file mode 100644
index 3a5aa19..0000000
--- a/CodeQualityMatricesProject/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_4_4.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/libraries/Maven__org_json_json_20160810.xml b/CodeQualityMatricesProject/.idea/libraries/Maven__org_json_json_20160810.xml
deleted file mode 100644
index 774f062..0000000
--- a/CodeQualityMatricesProject/.idea/libraries/Maven__org_json_json_20160810.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/misc.xml b/CodeQualityMatricesProject/.idea/misc.xml
deleted file mode 100644
index ff20635..0000000
--- a/CodeQualityMatricesProject/.idea/misc.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/modules.xml b/CodeQualityMatricesProject/.idea/modules.xml
deleted file mode 100644
index 0b9f2ed..0000000
--- a/CodeQualityMatricesProject/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/uiDesigner.xml b/CodeQualityMatricesProject/.idea/uiDesigner.xml
deleted file mode 100644
index e96534f..0000000
--- a/CodeQualityMatricesProject/.idea/uiDesigner.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.idea/vcs.xml b/CodeQualityMatricesProject/.idea/vcs.xml
deleted file mode 100644
index 6c0b863..0000000
--- a/CodeQualityMatricesProject/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/.project b/CodeQualityMatricesProject/.project
deleted file mode 100644
index 8097dc1..0000000
--- a/CodeQualityMatricesProject/.project
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- CodeQualityMatricesProject
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.m2e.core.maven2Builder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.m2e.core.maven2Nature
-
-
diff --git a/CodeQualityMatricesProject/.settings/org.eclipse.core.resources.prefs b/CodeQualityMatricesProject/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index f9fe345..0000000
--- a/CodeQualityMatricesProject/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-encoding//src/main/java=UTF-8
-encoding//src/test/java=UTF-8
-encoding/=UTF-8
diff --git a/CodeQualityMatricesProject/.settings/org.eclipse.jdt.core.prefs b/CodeQualityMatricesProject/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 6249222..0000000
--- a/CodeQualityMatricesProject/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.7
diff --git a/CodeQualityMatricesProject/.settings/org.eclipse.m2e.core.prefs b/CodeQualityMatricesProject/.settings/org.eclipse.m2e.core.prefs
deleted file mode 100644
index f897a7f..0000000
--- a/CodeQualityMatricesProject/.settings/org.eclipse.m2e.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-activeProfiles=
-eclipse.preferences.version=1
-resolveWorkspaceProjects=true
-version=1
diff --git a/CodeQualityMatricesProject/CodeQualityMatrices.iml b/CodeQualityMatricesProject/CodeQualityMatrices.iml
deleted file mode 100644
index 264db63..0000000
--- a/CodeQualityMatricesProject/CodeQualityMatrices.iml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1120.json b/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1120.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1120.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1584.json b/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1584.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1584.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1590.json b/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1590.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1590.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1594.json b/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1594.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1594.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1618.json b/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1618.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1618.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1703.json b/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1703.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor1703.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor178.json b/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor178.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor178.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor2868.json b/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor2868.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor2868.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor2873.json b/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor2873.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor2873.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor53.json b/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor53.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor53.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor656.json b/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor656.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor656.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor657.json b/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor657.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/ReviewApiOutputs/wso2/carbon-apimgt/ReviewFor657.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/jsonOutPutFileCommits.json b/CodeQualityMatricesProject/jsonOutPutFileCommits.json
deleted file mode 100644
index f4e3c4f..0000000
--- a/CodeQualityMatricesProject/jsonOutPutFileCommits.json
+++ /dev/null
@@ -1 +0,0 @@
-[{"name":"jiraInformation_supportJiras","value":["https://support.wso2.com/jira/browse/YENLOSUPPORTDEV-7"]},{"name":"overview_carbonPlatform","value":["4.4.0"]},{"name":"overview_issueType","value":["Bug"]},{"name":"patchInformation_svnRevisionpublic","value":["eaa45529cbabc5f30a2ffaa4781821ad0a5223ab","2b1d973d089ebc3af3b9e7b893f48cf905758cf4"]},{"name":"peopleInvolved_developedby","value":["samitha@wso2.com"]},{"name":"registry.Aspects","value":["PatchLifeCycle"]},{"name":"patchInformation_zipLocation","value":["https://svn.wso2.com/wso2/custom/projects/projects/carbon/wilkes/patches/patch0680/WSO2-CARBON-PATCH-4.4.0-0680.zip"]},{"name":"dates_releasedOn","value":["12/20/2016"]},{"name":"wum_releasedTimestamp","value":["1482238832449"]},{"name":"patchInformation_isthisabackportpatch","value":["yes"]},{"name":"testInformation_reasonCannotDo","value":["Test implementation is not supported by test framework"]},{"name":"dates_qaStartedOn","value":["12/15/2016"]},{"name":"jiraInformation_publicjirasummary","value":["Support SSO without enabling single logout"]},{"name":"testInformation_regressionTests","value":["Setup APIM Store and Publisher web apps SSO with IS 5.1.0 without enabling Single Logout\nBasic login flow should work without getting a 500 Internal Server Error in the last step of the SSO flow (user redirecting back to Store or Publisher web app).\n"]},{"name":"dates_developmentStartedOn","value":["12/09/2016"]},{"name":"jiraInformation_publicJira","value":["https://wso2.org/jira/browse/APIMANAGER-4610"]},{"name":"testInformation_automationavailable","value":["Yes"]},{"name":"patchInformation_svnRevisionsupport","value":["a663444d6a8f76dd77a164b5d76750be3722ab38"]},{"name":"patchInformation_pleaseupdatehereifthejarisaspecialcase","value":["https://docs.google.com/a/wso2.com/spreadsheet/ccc?key=0AlTtjx4c_xVpdFBMY1pSdFFoc1EzY2R6V2JrQ3R3TUE#gid=0"]},{"name":"testInformation_testsRevisionsupport","value":["caee3a2b0bb6f21575ad439b29779e8bd4905680"]},{"name":"peopleInvolved_qaedby","value":["samitha@wso2.com"]},{"name":"overview_products","value":["API Manager 2.0.0"]},{"name":"registry.lifecycle.PatchLifeCycle.state","value":["Released"]},{"name":"overview_client","value":["Yenlo BV - Development Support"]},{"name":"patchInformation_qareferencelink","value":["https://support.wso2.com/jira/browse/WSOQATESTC-775"]},{"name":"registry.LC.name","value":["PatchLifeCycle"]},{"name":"overview_name","value":["WSO2-CARBON-PATCH-4.4.0-0680"]},{"name":"testInformation_testsRevisionpublic","value":["caee3a2b0bb6f21575ad439b29779e8bd4905680"]},{"name":"testInformation_automationTestsLocation","value":["https://github.com/wso2-support/product-apim/blob/support-2.0.0/modules/integration/tests-ui-integration/src/test/java/org/wso2/am/integration/ui/tests/APIMANAGER3277SSOLogin.java"]},{"name":"patchInformation_jarsInvolved","value":["org.wso2.carbon.hostobjects.sso_6.0.4.jar"]}]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/jsonOutPutFileOfSearchCommitAPI.json b/CodeQualityMatricesProject/jsonOutPutFileOfSearchCommitAPI.json
deleted file mode 100644
index 93827bd..0000000
--- a/CodeQualityMatricesProject/jsonOutPutFileOfSearchCommitAPI.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":1,"incomplete_results":false,"items":[{"url":"https://api.github.com/repos/wso2/carbon-apimgt/commits/2b1d973d089ebc3af3b9e7b893f48cf905758cf4","sha":"2b1d973d089ebc3af3b9e7b893f48cf905758cf4","html_url":"https://github.com/wso2/carbon-apimgt/commit/2b1d973d089ebc3af3b9e7b893f48cf905758cf4","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/commits/2b1d973d089ebc3af3b9e7b893f48cf905758cf4/comments","commit":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/git/commits/2b1d973d089ebc3af3b9e7b893f48cf905758cf4","author":{"date":"2016-08-16T16:38:48+05:30","name":"Malintha Amarasinghe","email":"malintha.prasan@gmail.com"},"committer":{"date":"2016-08-16T16:38:54+05:30","name":"Malintha Amarasinghe","email":"malintha.prasan@gmail.com"},"message":"sending ACS and signed SAML requests in Publisher","tree":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/git/trees/6bc4717c4b291fbbbb1726857d8c6eee7090104c","sha":"6bc4717c4b291fbbbb1726857d8c6eee7090104c"},"comment_count":0},"author":{"login":"malinthaprasan","id":1591316,"avatar_url":"https://avatars.githubusercontent.com/u/1591316?v=3","gravatar_id":"","url":"https://api.github.com/users/malinthaprasan","html_url":"https://github.com/malinthaprasan","followers_url":"https://api.github.com/users/malinthaprasan/followers","following_url":"https://api.github.com/users/malinthaprasan/following{/other_user}","gists_url":"https://api.github.com/users/malinthaprasan/gists{/gist_id}","starred_url":"https://api.github.com/users/malinthaprasan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malinthaprasan/subscriptions","organizations_url":"https://api.github.com/users/malinthaprasan/orgs","repos_url":"https://api.github.com/users/malinthaprasan/repos","events_url":"https://api.github.com/users/malinthaprasan/events{/privacy}","received_events_url":"https://api.github.com/users/malinthaprasan/received_events","type":"User","site_admin":false},"committer":{"login":"malinthaprasan","id":1591316,"avatar_url":"https://avatars.githubusercontent.com/u/1591316?v=3","gravatar_id":"","url":"https://api.github.com/users/malinthaprasan","html_url":"https://github.com/malinthaprasan","followers_url":"https://api.github.com/users/malinthaprasan/followers","following_url":"https://api.github.com/users/malinthaprasan/following{/other_user}","gists_url":"https://api.github.com/users/malinthaprasan/gists{/gist_id}","starred_url":"https://api.github.com/users/malinthaprasan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malinthaprasan/subscriptions","organizations_url":"https://api.github.com/users/malinthaprasan/orgs","repos_url":"https://api.github.com/users/malinthaprasan/repos","events_url":"https://api.github.com/users/malinthaprasan/events{/privacy}","received_events_url":"https://api.github.com/users/malinthaprasan/received_events","type":"User","site_admin":false},"parents":[{"url":"https://api.github.com/repos/wso2/carbon-apimgt/commits/eaa45529cbabc5f30a2ffaa4781821ad0a5223ab","html_url":"https://github.com/wso2/carbon-apimgt/commit/eaa45529cbabc5f30a2ffaa4781821ad0a5223ab","sha":"eaa45529cbabc5f30a2ffaa4781821ad0a5223ab"}],"repository":{"id":17201744,"name":"carbon-apimgt","full_name":"wso2/carbon-apimgt","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/carbon-apimgt","description":null,"fork":false,"url":"https://api.github.com/repos/wso2/carbon-apimgt","forks_url":"https://api.github.com/repos/wso2/carbon-apimgt/forks","keys_url":"https://api.github.com/repos/wso2/carbon-apimgt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/carbon-apimgt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/carbon-apimgt/teams","hooks_url":"https://api.github.com/repos/wso2/carbon-apimgt/hooks","issue_events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/events","assignees_url":"https://api.github.com/repos/wso2/carbon-apimgt/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/carbon-apimgt/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/carbon-apimgt/tags","blobs_url":"https://api.github.com/repos/wso2/carbon-apimgt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/carbon-apimgt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/carbon-apimgt/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/carbon-apimgt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/carbon-apimgt/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/carbon-apimgt/languages","stargazers_url":"https://api.github.com/repos/wso2/carbon-apimgt/stargazers","contributors_url":"https://api.github.com/repos/wso2/carbon-apimgt/contributors","subscribers_url":"https://api.github.com/repos/wso2/carbon-apimgt/subscribers","subscription_url":"https://api.github.com/repos/wso2/carbon-apimgt/subscription","commits_url":"https://api.github.com/repos/wso2/carbon-apimgt/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/carbon-apimgt/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/carbon-apimgt/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/carbon-apimgt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/carbon-apimgt/merges","archive_url":"https://api.github.com/repos/wso2/carbon-apimgt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/carbon-apimgt/downloads","issues_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/carbon-apimgt/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/carbon-apimgt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/labels{/name}","releases_url":"https://api.github.com/repos/wso2/carbon-apimgt/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/carbon-apimgt/deployments"},"score":1.0}]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/jsonOutPutFilePRs.json b/CodeQualityMatricesProject/jsonOutPutFilePRs.json
deleted file mode 100644
index c818f7f..0000000
--- a/CodeQualityMatricesProject/jsonOutPutFilePRs.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":3,"incomplete_results":false,"items":[{"url":"https://api.github.com/repos/wso2/carbon-kernel/issues/524","repository_url":"https://api.github.com/repos/wso2/carbon-kernel","labels_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/524/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/524/comments","events_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/524/events","html_url":"https://github.com/wso2/carbon-kernel/pull/524","id":110054673,"number":524,"title":"Fixing IDENTITY-3363","user":{"login":"damithsenanayake","id":1591344,"avatar_url":"https://avatars.githubusercontent.com/u/1591344?v=3","gravatar_id":"","url":"https://api.github.com/users/damithsenanayake","html_url":"https://github.com/damithsenanayake","followers_url":"https://api.github.com/users/damithsenanayake/followers","following_url":"https://api.github.com/users/damithsenanayake/following{/other_user}","gists_url":"https://api.github.com/users/damithsenanayake/gists{/gist_id}","starred_url":"https://api.github.com/users/damithsenanayake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damithsenanayake/subscriptions","organizations_url":"https://api.github.com/users/damithsenanayake/orgs","repos_url":"https://api.github.com/users/damithsenanayake/repos","events_url":"https://api.github.com/users/damithsenanayake/events{/privacy}","received_events_url":"https://api.github.com/users/damithsenanayake/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2015-10-06T17:06:37Z","updated_at":"2015-10-12T09:19:24Z","closed_at":"2015-10-12T09:19:24Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-kernel/pulls/524","html_url":"https://github.com/wso2/carbon-kernel/pull/524","diff_url":"https://github.com/wso2/carbon-kernel/pull/524.diff","patch_url":"https://github.com/wso2/carbon-kernel/pull/524.patch"},"body":"","score":0.4839668},{"url":"https://api.github.com/repos/wso2/carbon-kernel/issues/573","repository_url":"https://api.github.com/repos/wso2/carbon-kernel","labels_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/573/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/573/comments","events_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/573/events","html_url":"https://github.com/wso2/carbon-kernel/pull/573","id":112377096,"number":573,"title":"Identity 3874 44x","user":{"login":"damithsenanayake","id":1591344,"avatar_url":"https://avatars.githubusercontent.com/u/1591344?v=3","gravatar_id":"","url":"https://api.github.com/users/damithsenanayake","html_url":"https://github.com/damithsenanayake","followers_url":"https://api.github.com/users/damithsenanayake/followers","following_url":"https://api.github.com/users/damithsenanayake/following{/other_user}","gists_url":"https://api.github.com/users/damithsenanayake/gists{/gist_id}","starred_url":"https://api.github.com/users/damithsenanayake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damithsenanayake/subscriptions","organizations_url":"https://api.github.com/users/damithsenanayake/orgs","repos_url":"https://api.github.com/users/damithsenanayake/repos","events_url":"https://api.github.com/users/damithsenanayake/events{/privacy}","received_events_url":"https://api.github.com/users/damithsenanayake/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2015-10-20T14:08:23Z","updated_at":"2015-10-20T14:08:34Z","closed_at":"2015-10-20T14:08:34Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-kernel/pulls/573","html_url":"https://github.com/wso2/carbon-kernel/pull/573","diff_url":"https://github.com/wso2/carbon-kernel/pull/573.diff","patch_url":"https://github.com/wso2/carbon-kernel/pull/573.patch"},"body":"","score":0.4839668},{"url":"https://api.github.com/repos/IndunilRathnayake/carbon4-kernel/issues/1","repository_url":"https://api.github.com/repos/IndunilRathnayake/carbon4-kernel","labels_url":"https://api.github.com/repos/IndunilRathnayake/carbon4-kernel/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/IndunilRathnayake/carbon4-kernel/issues/1/comments","events_url":"https://api.github.com/repos/IndunilRathnayake/carbon4-kernel/issues/1/events","html_url":"https://github.com/IndunilRathnayake/carbon4-kernel/pull/1","id":119506644,"number":1,"title":"Crypto","user":{"login":"cdwijayarathna","id":1338607,"avatar_url":"https://avatars.githubusercontent.com/u/1338607?v=3","gravatar_id":"","url":"https://api.github.com/users/cdwijayarathna","html_url":"https://github.com/cdwijayarathna","followers_url":"https://api.github.com/users/cdwijayarathna/followers","following_url":"https://api.github.com/users/cdwijayarathna/following{/other_user}","gists_url":"https://api.github.com/users/cdwijayarathna/gists{/gist_id}","starred_url":"https://api.github.com/users/cdwijayarathna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdwijayarathna/subscriptions","organizations_url":"https://api.github.com/users/cdwijayarathna/orgs","repos_url":"https://api.github.com/users/cdwijayarathna/repos","events_url":"https://api.github.com/users/cdwijayarathna/events{/privacy}","received_events_url":"https://api.github.com/users/cdwijayarathna/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2015-11-30T14:46:19Z","updated_at":"2015-11-30T14:47:47Z","closed_at":"2015-11-30T14:47:47Z","pull_request":{"url":"https://api.github.com/repos/IndunilRathnayake/carbon4-kernel/pulls/1","html_url":"https://github.com/IndunilRathnayake/carbon4-kernel/pull/1","diff_url":"https://github.com/IndunilRathnayake/carbon4-kernel/pull/1.diff","patch_url":"https://github.com/IndunilRathnayake/carbon4-kernel/pull/1.patch"},"body":"","score":0.48394772}]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/pom.xml b/CodeQualityMatricesProject/pom.xml
deleted file mode 100644
index cfb894e..0000000
--- a/CodeQualityMatricesProject/pom.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
- 4.0.0
-
- kasun.codeQualityMatrices
- CodeQualityMatrices
- 0.0.1-SNAPSHOT
- jar
-
- CodeQualityMatrices
- http://maven.apache.org
-
-
- 1.7
- UTF-8
-
-
-
-
- junit
- junit
- 3.8.1
- test
-
-
-
- org.json
- json
- 20160810
-
-
-
- org.apache.httpcomponents
- httpclient
- 4.5.2
-
-
-
- com.googlecode.json-simple
- json-simple
- 1.1.1
-
-
-
- org.apache.commons
- commons-lang3
- 3.5
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.1
-
-
- 1.8
-
-
-
-
-
diff --git a/CodeQualityMatricesProject/pullOutput.json b/CodeQualityMatricesProject/pullOutput.json
deleted file mode 100644
index 0960714..0000000
--- a/CodeQualityMatricesProject/pullOutput.json
+++ /dev/null
@@ -1 +0,0 @@
-{"url":"https://api.github.com/repos/wso2/carbon-kernel/pulls/524","id":46930122,"html_url":"https://github.com/wso2/carbon-kernel/pull/524","diff_url":"https://github.com/wso2/carbon-kernel/pull/524.diff","patch_url":"https://github.com/wso2/carbon-kernel/pull/524.patch","issue_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/524","number":524,"state":"closed","locked":false,"title":"Fixing IDENTITY-3363","user":{"login":"damithsenanayake","id":1591344,"avatar_url":"https://avatars.githubusercontent.com/u/1591344?v=3","gravatar_id":"","url":"https://api.github.com/users/damithsenanayake","html_url":"https://github.com/damithsenanayake","followers_url":"https://api.github.com/users/damithsenanayake/followers","following_url":"https://api.github.com/users/damithsenanayake/following{/other_user}","gists_url":"https://api.github.com/users/damithsenanayake/gists{/gist_id}","starred_url":"https://api.github.com/users/damithsenanayake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damithsenanayake/subscriptions","organizations_url":"https://api.github.com/users/damithsenanayake/orgs","repos_url":"https://api.github.com/users/damithsenanayake/repos","events_url":"https://api.github.com/users/damithsenanayake/events{/privacy}","received_events_url":"https://api.github.com/users/damithsenanayake/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-06T17:06:37Z","updated_at":"2015-10-12T09:19:24Z","closed_at":"2015-10-12T09:19:24Z","merged_at":null,"merge_commit_sha":"d83c111609bcb4d73c8de301f55a42aad5363f52","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/wso2/carbon-kernel/pulls/524/commits","review_comments_url":"https://api.github.com/repos/wso2/carbon-kernel/pulls/524/comments","review_comment_url":"https://api.github.com/repos/wso2/carbon-kernel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/524/comments","statuses_url":"https://api.github.com/repos/wso2/carbon-kernel/statuses/88b1cf36231c296a38c4804d851fa875dba652b1","head":{"label":"damithsenanayake:identity-3363-4.4.x","ref":"identity-3363-4.4.x","sha":"88b1cf36231c296a38c4804d851fa875dba652b1","user":{"login":"damithsenanayake","id":1591344,"avatar_url":"https://avatars.githubusercontent.com/u/1591344?v=3","gravatar_id":"","url":"https://api.github.com/users/damithsenanayake","html_url":"https://github.com/damithsenanayake","followers_url":"https://api.github.com/users/damithsenanayake/followers","following_url":"https://api.github.com/users/damithsenanayake/following{/other_user}","gists_url":"https://api.github.com/users/damithsenanayake/gists{/gist_id}","starred_url":"https://api.github.com/users/damithsenanayake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damithsenanayake/subscriptions","organizations_url":"https://api.github.com/users/damithsenanayake/orgs","repos_url":"https://api.github.com/users/damithsenanayake/repos","events_url":"https://api.github.com/users/damithsenanayake/events{/privacy}","received_events_url":"https://api.github.com/users/damithsenanayake/received_events","type":"User","site_admin":false},"repo":{"id":37578769,"name":"carbon-kernel","full_name":"damithsenanayake/carbon-kernel","owner":{"login":"damithsenanayake","id":1591344,"avatar_url":"https://avatars.githubusercontent.com/u/1591344?v=3","gravatar_id":"","url":"https://api.github.com/users/damithsenanayake","html_url":"https://github.com/damithsenanayake","followers_url":"https://api.github.com/users/damithsenanayake/followers","following_url":"https://api.github.com/users/damithsenanayake/following{/other_user}","gists_url":"https://api.github.com/users/damithsenanayake/gists{/gist_id}","starred_url":"https://api.github.com/users/damithsenanayake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damithsenanayake/subscriptions","organizations_url":"https://api.github.com/users/damithsenanayake/orgs","repos_url":"https://api.github.com/users/damithsenanayake/repos","events_url":"https://api.github.com/users/damithsenanayake/events{/privacy}","received_events_url":"https://api.github.com/users/damithsenanayake/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/damithsenanayake/carbon-kernel","description":null,"fork":true,"url":"https://api.github.com/repos/damithsenanayake/carbon-kernel","forks_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/forks","keys_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/teams","hooks_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/hooks","issue_events_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/issues/events{/number}","events_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/events","assignees_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/assignees{/user}","branches_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/branches{/branch}","tags_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/tags","blobs_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/git/refs{/sha}","trees_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/statuses/{sha}","languages_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/languages","stargazers_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/stargazers","contributors_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/contributors","subscribers_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/subscribers","subscription_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/subscription","commits_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/commits{/sha}","git_commits_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/git/commits{/sha}","comments_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/comments{/number}","issue_comment_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/issues/comments{/number}","contents_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/contents/{+path}","compare_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/merges","archive_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/downloads","issues_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/issues{/number}","pulls_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/pulls{/number}","milestones_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/milestones{/number}","notifications_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/labels{/name}","releases_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/releases{/id}","deployments_url":"https://api.github.com/repos/damithsenanayake/carbon-kernel/deployments","created_at":"2015-06-17T07:11:33Z","updated_at":"2015-11-17T11:19:33Z","pushed_at":"2016-02-05T06:52:37Z","git_url":"git://github.com/damithsenanayake/carbon-kernel.git","ssh_url":"git@github.com:damithsenanayake/carbon-kernel.git","clone_url":"https://github.com/damithsenanayake/carbon-kernel.git","svn_url":"https://github.com/damithsenanayake/carbon-kernel","homepage":null,"size":38339,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"wso2:4.4.x","ref":"4.4.x","sha":"8295cc2b7b00c2399d67447d17d02f9ce78683be","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":16162184,"name":"carbon-kernel","full_name":"wso2/carbon-kernel","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/carbon-kernel","description":null,"fork":false,"url":"https://api.github.com/repos/wso2/carbon-kernel","forks_url":"https://api.github.com/repos/wso2/carbon-kernel/forks","keys_url":"https://api.github.com/repos/wso2/carbon-kernel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/carbon-kernel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/carbon-kernel/teams","hooks_url":"https://api.github.com/repos/wso2/carbon-kernel/hooks","issue_events_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/carbon-kernel/events","assignees_url":"https://api.github.com/repos/wso2/carbon-kernel/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/carbon-kernel/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/carbon-kernel/tags","blobs_url":"https://api.github.com/repos/wso2/carbon-kernel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/carbon-kernel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/carbon-kernel/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/carbon-kernel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/carbon-kernel/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/carbon-kernel/languages","stargazers_url":"https://api.github.com/repos/wso2/carbon-kernel/stargazers","contributors_url":"https://api.github.com/repos/wso2/carbon-kernel/contributors","subscribers_url":"https://api.github.com/repos/wso2/carbon-kernel/subscribers","subscription_url":"https://api.github.com/repos/wso2/carbon-kernel/subscription","commits_url":"https://api.github.com/repos/wso2/carbon-kernel/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/carbon-kernel/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/carbon-kernel/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/carbon-kernel/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/carbon-kernel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/carbon-kernel/merges","archive_url":"https://api.github.com/repos/wso2/carbon-kernel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/carbon-kernel/downloads","issues_url":"https://api.github.com/repos/wso2/carbon-kernel/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/carbon-kernel/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/carbon-kernel/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/carbon-kernel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/carbon-kernel/labels{/name}","releases_url":"https://api.github.com/repos/wso2/carbon-kernel/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/carbon-kernel/deployments","created_at":"2014-01-23T04:23:41Z","updated_at":"2017-01-03T08:52:18Z","pushed_at":"2017-01-27T05:07:57Z","git_url":"git://github.com/wso2/carbon-kernel.git","ssh_url":"git@github.com:wso2/carbon-kernel.git","clone_url":"https://github.com/wso2/carbon-kernel.git","svn_url":"https://github.com/wso2/carbon-kernel","homepage":null,"size":45210,"stargazers_count":38,"watchers_count":38,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":289,"mirror_url":null,"open_issues_count":31,"forks":289,"open_issues":31,"watchers":38,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-kernel/pulls/524"},"html":{"href":"https://github.com/wso2/carbon-kernel/pull/524"},"issue":{"href":"https://api.github.com/repos/wso2/carbon-kernel/issues/524"},"comments":{"href":"https://api.github.com/repos/wso2/carbon-kernel/issues/524/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/carbon-kernel/pulls/524/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/carbon-kernel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/carbon-kernel/pulls/524/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/carbon-kernel/statuses/88b1cf36231c296a38c4804d851fa875dba652b1"}},"merged":false,"mergeable":false,"mergeable_state":"dirty","merged_by":null,"comments":4,"review_comments":0,"maintainer_can_modify":false,"commits":7,"additions":37,"deletions":5,"changed_files":6}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/pullReviewOutPutFile.json b/CodeQualityMatricesProject/pullReviewOutPutFile.json
deleted file mode 100644
index 0637a08..0000000
--- a/CodeQualityMatricesProject/pullReviewOutPutFile.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/searchApiOutputs/0015c02145c8ec6d3bba433f2fb5e850e1d25846.json b/CodeQualityMatricesProject/searchApiOutputs/0015c02145c8ec6d3bba433f2fb5e850e1d25846.json
deleted file mode 100644
index 7334345..0000000
--- a/CodeQualityMatricesProject/searchApiOutputs/0015c02145c8ec6d3bba433f2fb5e850e1d25846.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":2,"incomplete_results":false,"items":[{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/657","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/657/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/657/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/657/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/657","id":86646396,"number":657,"title":"Adding sso-hostobject","user":{"login":"jaadds","id":9979804,"avatar_url":"https://avatars.githubusercontent.com/u/9979804?v=3","gravatar_id":"","url":"https://api.github.com/users/jaadds","html_url":"https://github.com/jaadds","followers_url":"https://api.github.com/users/jaadds/followers","following_url":"https://api.github.com/users/jaadds/following{/other_user}","gists_url":"https://api.github.com/users/jaadds/gists{/gist_id}","starred_url":"https://api.github.com/users/jaadds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaadds/subscriptions","organizations_url":"https://api.github.com/users/jaadds/orgs","repos_url":"https://api.github.com/users/jaadds/repos","events_url":"https://api.github.com/users/jaadds/events{/privacy}","received_events_url":"https://api.github.com/users/jaadds/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2015-06-09T15:54:08Z","updated_at":"2015-06-09T15:54:16Z","closed_at":"2015-06-09T15:54:16Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/657","html_url":"https://github.com/wso2/carbon-apimgt/pull/657","diff_url":"https://github.com/wso2/carbon-apimgt/pull/657.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/657.patch"},"body":"","score":0.48381817},{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/656","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/656/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/656/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/656/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/656","id":86642184,"number":656,"title":"Passive SSO support for API Store","user":{"login":"malinthaprasan","id":1591316,"avatar_url":"https://avatars.githubusercontent.com/u/1591316?v=3","gravatar_id":"","url":"https://api.github.com/users/malinthaprasan","html_url":"https://github.com/malinthaprasan","followers_url":"https://api.github.com/users/malinthaprasan/followers","following_url":"https://api.github.com/users/malinthaprasan/following{/other_user}","gists_url":"https://api.github.com/users/malinthaprasan/gists{/gist_id}","starred_url":"https://api.github.com/users/malinthaprasan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malinthaprasan/subscriptions","organizations_url":"https://api.github.com/users/malinthaprasan/orgs","repos_url":"https://api.github.com/users/malinthaprasan/repos","events_url":"https://api.github.com/users/malinthaprasan/events{/privacy}","received_events_url":"https://api.github.com/users/malinthaprasan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2015-06-09T15:41:21Z","updated_at":"2015-11-29T13:17:51Z","closed_at":"2015-06-09T17:03:44Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/656","html_url":"https://github.com/wso2/carbon-apimgt/pull/656","diff_url":"https://github.com/wso2/carbon-apimgt/pull/656.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/656.patch"},"body":"","score":0.48381817}]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/searchApiOutputs/653f5325075702fb2367743559ffc03d2b596cfd.json b/CodeQualityMatricesProject/searchApiOutputs/653f5325075702fb2367743559ffc03d2b596cfd.json
deleted file mode 100644
index 988bccc..0000000
--- a/CodeQualityMatricesProject/searchApiOutputs/653f5325075702fb2367743559ffc03d2b596cfd.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":1,"incomplete_results":false,"items":[{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/53","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/53/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/53/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/53/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/53","id":60088673,"number":53,"title":"Remove hard dependency to the class 'WSO2ExternalAPIStore' Release 1.9.0","user":{"login":"binalip","id":8734514,"avatar_url":"https://avatars.githubusercontent.com/u/8734514?v=3","gravatar_id":"","url":"https://api.github.com/users/binalip","html_url":"https://github.com/binalip","followers_url":"https://api.github.com/users/binalip/followers","following_url":"https://api.github.com/users/binalip/following{/other_user}","gists_url":"https://api.github.com/users/binalip/gists{/gist_id}","starred_url":"https://api.github.com/users/binalip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/binalip/subscriptions","organizations_url":"https://api.github.com/users/binalip/orgs","repos_url":"https://api.github.com/users/binalip/repos","events_url":"https://api.github.com/users/binalip/events{/privacy}","received_events_url":"https://api.github.com/users/binalip/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2015-03-06T11:09:55Z","updated_at":"2015-03-06T11:35:08Z","closed_at":"2015-03-06T11:35:08Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/53","html_url":"https://github.com/wso2/carbon-apimgt/pull/53","diff_url":"https://github.com/wso2/carbon-apimgt/pull/53.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/53.patch"},"body":"'WSO2APIStore' class is no longer directly referred from the API Manager code. The class name for the external API store reads from the 'default-external-api-store.xml'.A new attribute which is 'class' is holding the name for the External API Store class.\n","score":0.48383135}]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/searchApiOutputs/75e02613db654fa15679f8e77bc282fcb30de3a9.json b/CodeQualityMatricesProject/searchApiOutputs/75e02613db654fa15679f8e77bc282fcb30de3a9.json
deleted file mode 100644
index 9191937..0000000
--- a/CodeQualityMatricesProject/searchApiOutputs/75e02613db654fa15679f8e77bc282fcb30de3a9.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":2,"incomplete_results":false,"items":[{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1590","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1590/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1590/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1590/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/1590","id":131551865,"number":1590,"title":"fix for APIMANAGER-4524","user":{"login":"chamilaadhi","id":4861150,"avatar_url":"https://avatars.githubusercontent.com/u/4861150?v=3","gravatar_id":"","url":"https://api.github.com/users/chamilaadhi","html_url":"https://github.com/chamilaadhi","followers_url":"https://api.github.com/users/chamilaadhi/followers","following_url":"https://api.github.com/users/chamilaadhi/following{/other_user}","gists_url":"https://api.github.com/users/chamilaadhi/gists{/gist_id}","starred_url":"https://api.github.com/users/chamilaadhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chamilaadhi/subscriptions","organizations_url":"https://api.github.com/users/chamilaadhi/orgs","repos_url":"https://api.github.com/users/chamilaadhi/repos","events_url":"https://api.github.com/users/chamilaadhi/events{/privacy}","received_events_url":"https://api.github.com/users/chamilaadhi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-02-05T04:29:59Z","updated_at":"2016-02-05T04:34:10Z","closed_at":"2016-02-05T04:34:10Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1590","html_url":"https://github.com/wso2/carbon-apimgt/pull/1590","diff_url":"https://github.com/wso2/carbon-apimgt/pull/1590.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/1590.patch"},"body":"","score":0.48383135},{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1594","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1594/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1594/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1594/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/1594","id":132100018,"number":1594,"title":"Merged Master to Release 1.11.x","user":{"login":"bhathiya","id":3960742,"avatar_url":"https://avatars.githubusercontent.com/u/3960742?v=3","gravatar_id":"","url":"https://api.github.com/users/bhathiya","html_url":"https://github.com/bhathiya","followers_url":"https://api.github.com/users/bhathiya/followers","following_url":"https://api.github.com/users/bhathiya/following{/other_user}","gists_url":"https://api.github.com/users/bhathiya/gists{/gist_id}","starred_url":"https://api.github.com/users/bhathiya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhathiya/subscriptions","organizations_url":"https://api.github.com/users/bhathiya/orgs","repos_url":"https://api.github.com/users/bhathiya/repos","events_url":"https://api.github.com/users/bhathiya/events{/privacy}","received_events_url":"https://api.github.com/users/bhathiya/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-02-08T10:11:51Z","updated_at":"2016-02-08T10:13:33Z","closed_at":"2016-02-08T10:13:33Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1594","html_url":"https://github.com/wso2/carbon-apimgt/pull/1594","diff_url":"https://github.com/wso2/carbon-apimgt/pull/1594.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/1594.patch"},"body":"","score":0.48383135}]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/searchApiOutputs/82dc0b0272253dcf21d222ad2ac19d35a71198d7.json b/CodeQualityMatricesProject/searchApiOutputs/82dc0b0272253dcf21d222ad2ac19d35a71198d7.json
deleted file mode 100644
index 5e58eeb..0000000
--- a/CodeQualityMatricesProject/searchApiOutputs/82dc0b0272253dcf21d222ad2ac19d35a71198d7.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":2,"incomplete_results":false,"items":[{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/178","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/178/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/178/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/178/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/178","id":67375724,"number":178,"title":"Fixing OIDC login in store and publisher","user":{"login":"ranga-siriwardena","id":8995220,"avatar_url":"https://avatars.githubusercontent.com/u/8995220?v=3","gravatar_id":"","url":"https://api.github.com/users/ranga-siriwardena","html_url":"https://github.com/ranga-siriwardena","followers_url":"https://api.github.com/users/ranga-siriwardena/followers","following_url":"https://api.github.com/users/ranga-siriwardena/following{/other_user}","gists_url":"https://api.github.com/users/ranga-siriwardena/gists{/gist_id}","starred_url":"https://api.github.com/users/ranga-siriwardena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ranga-siriwardena/subscriptions","organizations_url":"https://api.github.com/users/ranga-siriwardena/orgs","repos_url":"https://api.github.com/users/ranga-siriwardena/repos","events_url":"https://api.github.com/users/ranga-siriwardena/events{/privacy}","received_events_url":"https://api.github.com/users/ranga-siriwardena/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2015-04-09T14:35:35Z","updated_at":"2015-04-09T14:35:40Z","closed_at":"2015-04-09T14:35:40Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/178","html_url":"https://github.com/wso2/carbon-apimgt/pull/178","diff_url":"https://github.com/wso2/carbon-apimgt/pull/178.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/178.patch"},"body":"","score":0.48383135},{"url":"https://api.github.com/repos/udarakr/carbon-apimgt/issues/29","repository_url":"https://api.github.com/repos/udarakr/carbon-apimgt","labels_url":"https://api.github.com/repos/udarakr/carbon-apimgt/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/udarakr/carbon-apimgt/issues/29/comments","events_url":"https://api.github.com/repos/udarakr/carbon-apimgt/issues/29/events","html_url":"https://github.com/udarakr/carbon-apimgt/pull/29","id":81786218,"number":29,"title":"Sync with upstream","user":{"login":"udarakr","id":1343257,"avatar_url":"https://avatars.githubusercontent.com/u/1343257?v=3","gravatar_id":"","url":"https://api.github.com/users/udarakr","html_url":"https://github.com/udarakr","followers_url":"https://api.github.com/users/udarakr/followers","following_url":"https://api.github.com/users/udarakr/following{/other_user}","gists_url":"https://api.github.com/users/udarakr/gists{/gist_id}","starred_url":"https://api.github.com/users/udarakr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/udarakr/subscriptions","organizations_url":"https://api.github.com/users/udarakr/orgs","repos_url":"https://api.github.com/users/udarakr/repos","events_url":"https://api.github.com/users/udarakr/events{/privacy}","received_events_url":"https://api.github.com/users/udarakr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2015-05-28T06:28:48Z","updated_at":"2015-05-28T06:28:57Z","closed_at":"2015-05-28T06:28:57Z","pull_request":{"url":"https://api.github.com/repos/udarakr/carbon-apimgt/pulls/29","html_url":"https://github.com/udarakr/carbon-apimgt/pull/29","diff_url":"https://github.com/udarakr/carbon-apimgt/pull/29.diff","patch_url":"https://github.com/udarakr/carbon-apimgt/pull/29.patch"},"body":"","score":0.48383135}]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/searchApiOutputs/9f63d2f6ec285a65e69ec71765e55409db103e03.json b/CodeQualityMatricesProject/searchApiOutputs/9f63d2f6ec285a65e69ec71765e55409db103e03.json
deleted file mode 100644
index 6de1066..0000000
--- a/CodeQualityMatricesProject/searchApiOutputs/9f63d2f6ec285a65e69ec71765e55409db103e03.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":0,"incomplete_results":false,"items":[]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/searchApiOutputs/b483567c105e223d7edc397526017df22fe8aa43.json b/CodeQualityMatricesProject/searchApiOutputs/b483567c105e223d7edc397526017df22fe8aa43.json
deleted file mode 100644
index 6de1066..0000000
--- a/CodeQualityMatricesProject/searchApiOutputs/b483567c105e223d7edc397526017df22fe8aa43.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":0,"incomplete_results":false,"items":[]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/searchApiOutputs/cd4eb84b7cfd161b4dad565bcd698e824e1ec099.json b/CodeQualityMatricesProject/searchApiOutputs/cd4eb84b7cfd161b4dad565bcd698e824e1ec099.json
deleted file mode 100644
index ae55b35..0000000
--- a/CodeQualityMatricesProject/searchApiOutputs/cd4eb84b7cfd161b4dad565bcd698e824e1ec099.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":1,"incomplete_results":false,"items":[{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1703","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1703/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1703/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1703/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/1703","id":141521662,"number":1703,"title":"merge am feature branch to throttle-feature branch","user":{"login":"chamilaadhi","id":4861150,"avatar_url":"https://avatars.githubusercontent.com/u/4861150?v=3","gravatar_id":"","url":"https://api.github.com/users/chamilaadhi","html_url":"https://github.com/chamilaadhi","followers_url":"https://api.github.com/users/chamilaadhi/followers","following_url":"https://api.github.com/users/chamilaadhi/following{/other_user}","gists_url":"https://api.github.com/users/chamilaadhi/gists{/gist_id}","starred_url":"https://api.github.com/users/chamilaadhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chamilaadhi/subscriptions","organizations_url":"https://api.github.com/users/chamilaadhi/orgs","repos_url":"https://api.github.com/users/chamilaadhi/repos","events_url":"https://api.github.com/users/chamilaadhi/events{/privacy}","received_events_url":"https://api.github.com/users/chamilaadhi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-03-17T09:06:21Z","updated_at":"2016-03-17T09:06:29Z","closed_at":"2016-03-17T09:06:29Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1703","html_url":"https://github.com/wso2/carbon-apimgt/pull/1703","diff_url":"https://github.com/wso2/carbon-apimgt/pull/1703.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/1703.patch"},"body":"","score":0.48381817}]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/searchApiOutputs/dba207449a58b65ae9c7bdac6f60ce5ef474fb58.json b/CodeQualityMatricesProject/searchApiOutputs/dba207449a58b65ae9c7bdac6f60ce5ef474fb58.json
deleted file mode 100644
index 0f6f5c1..0000000
--- a/CodeQualityMatricesProject/searchApiOutputs/dba207449a58b65ae9c7bdac6f60ce5ef474fb58.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":3,"incomplete_results":false,"items":[{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/2868","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/2868/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/2868/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/2868/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/2868","id":167874806,"number":2868,"title":"Improvements to saml2 sso validations","user":{"login":"lalaji","id":1701148,"avatar_url":"https://avatars.githubusercontent.com/u/1701148?v=3","gravatar_id":"","url":"https://api.github.com/users/lalaji","html_url":"https://github.com/lalaji","followers_url":"https://api.github.com/users/lalaji/followers","following_url":"https://api.github.com/users/lalaji/following{/other_user}","gists_url":"https://api.github.com/users/lalaji/gists{/gist_id}","starred_url":"https://api.github.com/users/lalaji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lalaji/subscriptions","organizations_url":"https://api.github.com/users/lalaji/orgs","repos_url":"https://api.github.com/users/lalaji/repos","events_url":"https://api.github.com/users/lalaji/events{/privacy}","received_events_url":"https://api.github.com/users/lalaji/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-27T14:54:28Z","updated_at":"2016-07-27T14:55:22Z","closed_at":"2016-07-27T14:55:22Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/2868","html_url":"https://github.com/wso2/carbon-apimgt/pull/2868","diff_url":"https://github.com/wso2/carbon-apimgt/pull/2868.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/2868.patch"},"body":"","score":0.48381817},{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/2873","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/2873/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/2873/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/2873/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/2873","id":168296155,"number":2873,"title":"Merged release branch back to master","user":{"login":"abimarank","id":2951657,"avatar_url":"https://avatars.githubusercontent.com/u/2951657?v=3","gravatar_id":"","url":"https://api.github.com/users/abimarank","html_url":"https://github.com/abimarank","followers_url":"https://api.github.com/users/abimarank/followers","following_url":"https://api.github.com/users/abimarank/following{/other_user}","gists_url":"https://api.github.com/users/abimarank/gists{/gist_id}","starred_url":"https://api.github.com/users/abimarank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abimarank/subscriptions","organizations_url":"https://api.github.com/users/abimarank/orgs","repos_url":"https://api.github.com/users/abimarank/repos","events_url":"https://api.github.com/users/abimarank/events{/privacy}","received_events_url":"https://api.github.com/users/abimarank/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-29T10:27:10Z","updated_at":"2016-07-29T10:27:18Z","closed_at":"2016-07-29T10:27:17Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/2873","html_url":"https://github.com/wso2/carbon-apimgt/pull/2873","diff_url":"https://github.com/wso2/carbon-apimgt/pull/2873.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/2873.patch"},"body":"","score":0.48381817},{"url":"https://api.github.com/repos/sanjeewa-malalgoda/carbon-apimgt/issues/3","repository_url":"https://api.github.com/repos/sanjeewa-malalgoda/carbon-apimgt","labels_url":"https://api.github.com/repos/sanjeewa-malalgoda/carbon-apimgt/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/sanjeewa-malalgoda/carbon-apimgt/issues/3/comments","events_url":"https://api.github.com/repos/sanjeewa-malalgoda/carbon-apimgt/issues/3/events","html_url":"https://github.com/sanjeewa-malalgoda/carbon-apimgt/pull/3","id":172398042,"number":3,"title":"test1","user":{"login":"sanjeewa-malalgoda","id":7975153,"avatar_url":"https://avatars.githubusercontent.com/u/7975153?v=3","gravatar_id":"","url":"https://api.github.com/users/sanjeewa-malalgoda","html_url":"https://github.com/sanjeewa-malalgoda","followers_url":"https://api.github.com/users/sanjeewa-malalgoda/followers","following_url":"https://api.github.com/users/sanjeewa-malalgoda/following{/other_user}","gists_url":"https://api.github.com/users/sanjeewa-malalgoda/gists{/gist_id}","starred_url":"https://api.github.com/users/sanjeewa-malalgoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanjeewa-malalgoda/subscriptions","organizations_url":"https://api.github.com/users/sanjeewa-malalgoda/orgs","repos_url":"https://api.github.com/users/sanjeewa-malalgoda/repos","events_url":"https://api.github.com/users/sanjeewa-malalgoda/events{/privacy}","received_events_url":"https://api.github.com/users/sanjeewa-malalgoda/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-22T08:45:37Z","updated_at":"2017-01-03T07:09:02Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sanjeewa-malalgoda/carbon-apimgt/pulls/3","html_url":"https://github.com/sanjeewa-malalgoda/carbon-apimgt/pull/3","diff_url":"https://github.com/sanjeewa-malalgoda/carbon-apimgt/pull/3.diff","patch_url":"https://github.com/sanjeewa-malalgoda/carbon-apimgt/pull/3.patch"},"body":"","score":0.48378763}]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/searchApiOutputs/dce43d15b1d63af642cc562afc3c63812c45d84d.json b/CodeQualityMatricesProject/searchApiOutputs/dce43d15b1d63af642cc562afc3c63812c45d84d.json
deleted file mode 100644
index ea355dd..0000000
--- a/CodeQualityMatricesProject/searchApiOutputs/dce43d15b1d63af642cc562afc3c63812c45d84d.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":1,"incomplete_results":false,"items":[{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1120","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1120/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1120/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1120/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/1120","id":111578113,"number":1120,"title":"Adding missing codes with release-1.9.1 branch in /features","user":{"login":"malinthaprasan","id":1591316,"avatar_url":"https://avatars.githubusercontent.com/u/1591316?v=3","gravatar_id":"","url":"https://api.github.com/users/malinthaprasan","html_url":"https://github.com/malinthaprasan","followers_url":"https://api.github.com/users/malinthaprasan/followers","following_url":"https://api.github.com/users/malinthaprasan/following{/other_user}","gists_url":"https://api.github.com/users/malinthaprasan/gists{/gist_id}","starred_url":"https://api.github.com/users/malinthaprasan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malinthaprasan/subscriptions","organizations_url":"https://api.github.com/users/malinthaprasan/orgs","repos_url":"https://api.github.com/users/malinthaprasan/repos","events_url":"https://api.github.com/users/malinthaprasan/events{/privacy}","received_events_url":"https://api.github.com/users/malinthaprasan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2015-10-15T09:28:44Z","updated_at":"2015-10-15T09:32:20Z","closed_at":"2015-10-15T09:32:20Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1120","html_url":"https://github.com/wso2/carbon-apimgt/pull/1120","diff_url":"https://github.com/wso2/carbon-apimgt/pull/1120.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/1120.patch"},"body":"","score":0.48383135}]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/searchApiOutputs/eccc3deead1bc3e07ac281d0ab12cdc177206831.json b/CodeQualityMatricesProject/searchApiOutputs/eccc3deead1bc3e07ac281d0ab12cdc177206831.json
deleted file mode 100644
index e9abbbd..0000000
--- a/CodeQualityMatricesProject/searchApiOutputs/eccc3deead1bc3e07ac281d0ab12cdc177206831.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":2,"incomplete_results":false,"items":[{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1594","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1594/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1594/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1594/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/1594","id":132100018,"number":1594,"title":"Merged Master to Release 1.11.x","user":{"login":"bhathiya","id":3960742,"avatar_url":"https://avatars.githubusercontent.com/u/3960742?v=3","gravatar_id":"","url":"https://api.github.com/users/bhathiya","html_url":"https://github.com/bhathiya","followers_url":"https://api.github.com/users/bhathiya/followers","following_url":"https://api.github.com/users/bhathiya/following{/other_user}","gists_url":"https://api.github.com/users/bhathiya/gists{/gist_id}","starred_url":"https://api.github.com/users/bhathiya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhathiya/subscriptions","organizations_url":"https://api.github.com/users/bhathiya/orgs","repos_url":"https://api.github.com/users/bhathiya/repos","events_url":"https://api.github.com/users/bhathiya/events{/privacy}","received_events_url":"https://api.github.com/users/bhathiya/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-02-08T10:11:51Z","updated_at":"2016-02-08T10:13:33Z","closed_at":"2016-02-08T10:13:33Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1594","html_url":"https://github.com/wso2/carbon-apimgt/pull/1594","diff_url":"https://github.com/wso2/carbon-apimgt/pull/1594.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/1594.patch"},"body":"","score":0.48383135},{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1584","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1584/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1584/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1584/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/1584","id":130588153,"number":1584,"title":"fix for APIMANAGER-4509","user":{"login":"chamilaadhi","id":4861150,"avatar_url":"https://avatars.githubusercontent.com/u/4861150?v=3","gravatar_id":"","url":"https://api.github.com/users/chamilaadhi","html_url":"https://github.com/chamilaadhi","followers_url":"https://api.github.com/users/chamilaadhi/followers","following_url":"https://api.github.com/users/chamilaadhi/following{/other_user}","gists_url":"https://api.github.com/users/chamilaadhi/gists{/gist_id}","starred_url":"https://api.github.com/users/chamilaadhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chamilaadhi/subscriptions","organizations_url":"https://api.github.com/users/chamilaadhi/orgs","repos_url":"https://api.github.com/users/chamilaadhi/repos","events_url":"https://api.github.com/users/chamilaadhi/events{/privacy}","received_events_url":"https://api.github.com/users/chamilaadhi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-02-02T06:25:44Z","updated_at":"2016-02-02T06:25:52Z","closed_at":"2016-02-02T06:25:52Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1584","html_url":"https://github.com/wso2/carbon-apimgt/pull/1584","diff_url":"https://github.com/wso2/carbon-apimgt/pull/1584.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/1584.patch"},"body":"","score":0.48383135}]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/searchApiOutputs/f55747f2501215e8e56eb879b12998795315d15c.json b/CodeQualityMatricesProject/searchApiOutputs/f55747f2501215e8e56eb879b12998795315d15c.json
deleted file mode 100644
index b53e36a..0000000
--- a/CodeQualityMatricesProject/searchApiOutputs/f55747f2501215e8e56eb879b12998795315d15c.json
+++ /dev/null
@@ -1 +0,0 @@
-{"total_count":3,"incomplete_results":false,"items":[{"url":"https://api.github.com/repos/tharindu1st/carbon-apimgt/issues/6","repository_url":"https://api.github.com/repos/tharindu1st/carbon-apimgt","labels_url":"https://api.github.com/repos/tharindu1st/carbon-apimgt/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/tharindu1st/carbon-apimgt/issues/6/comments","events_url":"https://api.github.com/repos/tharindu1st/carbon-apimgt/issues/6/events","html_url":"https://github.com/tharindu1st/carbon-apimgt/pull/6","id":137556039,"number":6,"title":"Feature execution merge","user":{"login":"jranabahu","id":3318658,"avatar_url":"https://avatars.githubusercontent.com/u/3318658?v=3","gravatar_id":"","url":"https://api.github.com/users/jranabahu","html_url":"https://github.com/jranabahu","followers_url":"https://api.github.com/users/jranabahu/followers","following_url":"https://api.github.com/users/jranabahu/following{/other_user}","gists_url":"https://api.github.com/users/jranabahu/gists{/gist_id}","starred_url":"https://api.github.com/users/jranabahu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jranabahu/subscriptions","organizations_url":"https://api.github.com/users/jranabahu/orgs","repos_url":"https://api.github.com/users/jranabahu/repos","events_url":"https://api.github.com/users/jranabahu/events{/privacy}","received_events_url":"https://api.github.com/users/jranabahu/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-03-01T12:10:40Z","updated_at":"2016-03-01T12:11:23Z","closed_at":"2016-03-01T12:11:23Z","pull_request":{"url":"https://api.github.com/repos/tharindu1st/carbon-apimgt/pulls/6","html_url":"https://github.com/tharindu1st/carbon-apimgt/pull/6","diff_url":"https://github.com/tharindu1st/carbon-apimgt/pull/6.diff","patch_url":"https://github.com/tharindu1st/carbon-apimgt/pull/6.patch"},"body":"","score":0.48387566},{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1618","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1618/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1618/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1618/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/1618","id":133920071,"number":1618,"title":"Adding new wso2 bootstrap theme","user":{"login":"lakmali","id":3793436,"avatar_url":"https://avatars.githubusercontent.com/u/3793436?v=3","gravatar_id":"","url":"https://api.github.com/users/lakmali","html_url":"https://github.com/lakmali","followers_url":"https://api.github.com/users/lakmali/followers","following_url":"https://api.github.com/users/lakmali/following{/other_user}","gists_url":"https://api.github.com/users/lakmali/gists{/gist_id}","starred_url":"https://api.github.com/users/lakmali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lakmali/subscriptions","organizations_url":"https://api.github.com/users/lakmali/orgs","repos_url":"https://api.github.com/users/lakmali/repos","events_url":"https://api.github.com/users/lakmali/events{/privacy}","received_events_url":"https://api.github.com/users/lakmali/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-02-16T08:55:09Z","updated_at":"2016-02-16T08:57:14Z","closed_at":"2016-02-16T08:57:14Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1618","html_url":"https://github.com/wso2/carbon-apimgt/pull/1618","diff_url":"https://github.com/wso2/carbon-apimgt/pull/1618.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/1618.patch"},"body":"","score":0.4838181},{"url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1703","repository_url":"https://api.github.com/repos/wso2/carbon-apimgt","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1703/labels{/name}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1703/comments","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1703/events","html_url":"https://github.com/wso2/carbon-apimgt/pull/1703","id":141521662,"number":1703,"title":"merge am feature branch to throttle-feature branch","user":{"login":"chamilaadhi","id":4861150,"avatar_url":"https://avatars.githubusercontent.com/u/4861150?v=3","gravatar_id":"","url":"https://api.github.com/users/chamilaadhi","html_url":"https://github.com/chamilaadhi","followers_url":"https://api.github.com/users/chamilaadhi/followers","following_url":"https://api.github.com/users/chamilaadhi/following{/other_user}","gists_url":"https://api.github.com/users/chamilaadhi/gists{/gist_id}","starred_url":"https://api.github.com/users/chamilaadhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chamilaadhi/subscriptions","organizations_url":"https://api.github.com/users/chamilaadhi/orgs","repos_url":"https://api.github.com/users/chamilaadhi/repos","events_url":"https://api.github.com/users/chamilaadhi/events{/privacy}","received_events_url":"https://api.github.com/users/chamilaadhi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-03-17T09:06:21Z","updated_at":"2016-03-17T09:06:29Z","closed_at":"2016-03-17T09:06:29Z","pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1703","html_url":"https://github.com/wso2/carbon-apimgt/pull/1703","diff_url":"https://github.com/wso2/carbon-apimgt/pull/1703.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/1703.patch"},"body":"","score":0.4838181}]}
\ No newline at end of file
diff --git a/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/BlameCommit.java b/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/BlameCommit.java
deleted file mode 100644
index 51188a9..0000000
--- a/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/BlameCommit.java
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * Copyright (c) Jan 31, 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package com.wso2.code.quality.matrices;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-
-/**
- * This class is used for getting the blame information on relevant lines changeed from the given patch
- */
-
-public class BlameCommit extends RestApiCaller {
-
- private String urlForObtainingCommits, urlForGetingFilesChanged;
- protected ArrayList fileNames = new ArrayList();
- protected List> lineRangesChanged = new ArrayList>(); // for saving the line no that are changed
- JSONObject graphqlApiJsonObject = new JSONObject();
- Set commitHashesOfTheParent;
- Set authorNames = new HashSet(); //as the authors are for all the commits that exists in the relevant patch
- protected Set commitHashObtainedForPRReview = new HashSet(); // relevant commits in old file that need to find the PR Reviewers
- private String repoLocation[];
-
- public String getUrlForSearchingCommits() {
- return urlForObtainingCommits;
- }
-
- public void setUrlForSearchingCommits(String commitHash) {
- this.urlForObtainingCommits = "https://api.github.com/search/commits?q=hash%3A" + commitHash;
- }
-
- public String getUrlForGetingFilesChanged() {
- return urlForGetingFilesChanged;
- }
-
- public void setUrlForGetingFilesChanged(String repoName, String commitHash) {
- this.urlForGetingFilesChanged = "http://api.github.com/repos/" + repoName + "/commits/" + commitHash;
- }
-
- /**
- * This method is used for obtaining the repositories that contain the relevant commits belongs to the given patch
- *
- * @param gitHubToken Github token
- * @param commitsInTheGivenPatch Commits that belongs to the given patch
- * @param restApiCaller Instance of the RestApiCaller class for accessing the REST APIs
- * @return a Set containing the commit hashes that needs to be checked for reviewers
- */
- public Set obtainingRepoNamesForCommitHashes(String gitHubToken, String[] commitsInTheGivenPatch, RestApiCaller restApiCaller) {
-
- for (String commitHash : commitsInTheGivenPatch) {
- setUrlForSearchingCommits(commitHash);
- //calling the API calling method
- JSONObject jsonObject = (JSONObject) restApiCaller.callingTheAPI(getUrlForSearchingCommits(), gitHubToken, true, false);
- saveRepoNamesInAnArray(jsonObject, commitHash, gitHubToken);
- }
- return commitHashObtainedForPRReview;
- }
-
- /**
- * saving the Repo Names in the array and calling to Get files content
- *
- * @param rootJsonObject JSON object containing the repositories which are having the current selected commit from the given patch
- * @param commitHash the current selected commit hash
- * @param gitHubToken github token for accessing the github REST API
- */
-
- public void saveRepoNamesInAnArray(JSONObject rootJsonObject, String commitHash, String gitHubToken) {
- JSONArray jsonArrayOfItems = (JSONArray) rootJsonObject.get("items");
- // setting the size of the repoLocationArray
- repoLocation = new String[jsonArrayOfItems.length()];
- for (int i = 0; i < jsonArrayOfItems.length(); i++) {
- JSONObject jsonObject = (JSONObject) jsonArrayOfItems.get(i);
- JSONObject repositoryJsonObject = (JSONObject) jsonObject.get("repository");
- //adding the repo name to the array
- repoLocation[i] = (String) repositoryJsonObject.get("full_name");
- }
-
- // for running through the repoName Array
- for (int i = 0; i < repoLocation.length; i++) {
- if (StringUtils.contains(repoLocation[i], "wso2/")) {
- //clearing all the data in the current fileNames and lineRangesChanged arraylists for each repository
- fileNames.clear();
- lineRangesChanged.clear();
- //authorNames.clear();
- callingToGetFilesChanged(repoLocation[i], commitHash, gitHubToken);
- iteratingOver(repoLocation[i], commitHash, gitHubToken);
- }
- }
- // for printing the author names and commit hashes for a certain commit.
- System.out.println(authorNames);
- System.out.println(commitHashObtainedForPRReview);
- }
-
- /**
- * calling github single commit API to get files changed from the current selected commit in the current selected repository
- *
- * @param repoLocation current selected repository
- * @param commitHash current selected commit hash
- * @param gitHubToken github token for accessing github REST API
- */
- public void callingToGetFilesChanged(String repoLocation, String commitHash, String gitHubToken) {
- // setting the URL for calling github single commit API
- setUrlForGetingFilesChanged(repoLocation, commitHash);
- JSONObject rootJsonObject = null;
- //saving the commit details for the commit hash on the relevant repository
- rootJsonObject = (JSONObject) callingTheAPI(getUrlForGetingFilesChanged(), gitHubToken, false, false);
- //calling savingRelaventFileNamesAndEditLineNumbers method to read the above saved json output
- savingRelaventFileNamesAndEditLineNumbers(rootJsonObject);
- }
-
- /**
- * saving relevant file names and their changed line ranges from the current selected commit in the current selected repository
- *
- * @param rootJsonObject JSONObject received from the calling the single commit API in github
- */
- public void savingRelaventFileNamesAndEditLineNumbers(JSONObject rootJsonObject) {
- JSONArray fileJsonArray = (JSONArray) rootJsonObject.get("files");
- // to save one file at a time
- for (int i = 0; i < fileJsonArray.length(); i++) {
- JSONObject tempJsonObject = (JSONObject) fileJsonArray.get(i);
- String fileName = (String) tempJsonObject.get("filename");
- //saving the file name in the filename arraylist
- fileNames.add(fileName);
-
- //filtering only the line ranges that are modified and saving to a string array
- String patch = (String) tempJsonObject.get("patch");
- String lineChanges[] = StringUtils.substringsBetween(patch, "@@ ", " @@");
-
- //filtering the lines that existed in the previous file, that exists in the new file and saving them in to the same array
- for (int j = 0; j < lineChanges.length; j++) {
-
- //@@ -22,7 +22,7 @@
- String tempString = lineChanges[j];
- String lineRangeInTheOldFileBeingModified = StringUtils.substringBetween(tempString, "-", " +"); // for taking the authors and commit hashes of the previous lines
- String lineRangeInTheNewFileResultedFromModification = StringUtils.substringAfter(tempString, "+"); // for taking the parent commit
-
- int intialLineNoInOldFile = Integer.parseInt(StringUtils.substringBefore(lineRangeInTheOldFileBeingModified, ","));
- int tempEndLineNoInOldFile = Integer.parseInt(StringUtils.substringAfter(lineRangeInTheOldFileBeingModified, ","));
- int endLineNoOfOldFile;
- if (intialLineNoInOldFile != 0) {
- // to filterout the newly created files
- endLineNoOfOldFile = intialLineNoInOldFile + (tempEndLineNoInOldFile - 1);
- } else {
- endLineNoOfOldFile = tempEndLineNoInOldFile;
- }
- int intialLineNoInNewFile = Integer.parseInt(StringUtils.substringBefore(lineRangeInTheNewFileResultedFromModification, ","));
- int tempEndLineNoInNewFile = Integer.parseInt(StringUtils.substringAfter(lineRangeInTheNewFileResultedFromModification, ","));
- int endLineNoOfNewFile = intialLineNoInNewFile + (tempEndLineNoInNewFile - 1);
-
- // storing the line ranges that are being modified in the same array by replacing values
- lineChanges[j] = intialLineNoInOldFile + "," + endLineNoOfOldFile + "/" + intialLineNoInNewFile + "," + endLineNoOfNewFile;
- }
- ArrayList tempArrayList = new ArrayList<>(Arrays.asList(lineChanges));
- //adding to the array list which keep track of the line ranges which are being changed to the main arrayList
- lineRangesChanged.add(tempArrayList);
- }
- System.out.println("done saving file names and their relevant modification line ranges");
- System.out.println(fileNames);
- System.out.println(lineRangesChanged + "\n");
- }
-
- /**
- * This method will iterate over the saved filenames and their relevant changed line ranges and calls the github graphQL API
- * for getting blame details for each of the files
- *
- * @param repoLocation current selected repository
- * @param commitHash current selected repository
- * @param gitHubToken github token for accessing github GraphQL API
- */
- public void iteratingOver(String repoLocation, String commitHash, String gitHubToken) {
-
- // filtering the owner and the repository name from the repoLocation
- String owner = StringUtils.substringBefore(repoLocation, "/");
- String repositoryName = StringUtils.substringAfter(repoLocation, "/");
- // iterating over the fileNames arraylist for the given commit
- Iterator iteratorForFileNames = fileNames.iterator();
-
- while (iteratorForFileNames.hasNext()) {
- String fileName = (String) iteratorForFileNames.next();
- int index = fileNames.indexOf(fileName);
- // the relevant arraylist of changed lines for that file
- ArrayList arrayListOfRelevantChangedLines = lineRangesChanged.get(index);
- commitHashesOfTheParent = new HashSet<>(); // for storing the parent commit hashes for all the line ranges of the relevant file
- graphqlApiJsonObject.put("query", "{repository(owner:\"" + owner + "\",name:\"" + repositoryName + "\"){object(expression:\"" + commitHash + "\"){ ... on Commit{blame(path:\"" + fileName + "\"){ranges{startingLine endingLine age commit{history(first: 2) { edges { node { message url } } } author { name email } } } } } } } }");
-
- JSONObject rootJsonObject = null;
- try {
- // calling the graphql API for getting blame information for the current file and saving it in a location.
- rootJsonObject = (JSONObject) callingGraphQl(graphqlApiJsonObject, gitHubToken);
- } catch (IOException e) {
- e.printStackTrace();
- }
- // reading the above saved output for the current selected file name
- readingTheBlameReceivedForAFile(rootJsonObject, arrayListOfRelevantChangedLines, false);
-
- // parent commit hashes are stored in the arraylist for the given file
-
- iteratingOverForFindingAuthors(owner, repositoryName, fileName, arrayListOfRelevantChangedLines, gitHubToken);
- }
- }
-
- /**
- * Calling the github graphQL API
- *
- * @param queryObject the JSONObject required for querying
- * @param gitHubToken github token for accessing github GraphQL API
- * @return Depending on the content return a JSONObject or a JSONArray
- * @throws IOException
- */
- public Object callingGraphQl(JSONObject queryObject, String gitHubToken) throws IOException {
-
- CloseableHttpClient client = null;
- CloseableHttpResponse response = null;
- client = HttpClients.createDefault();
- HttpPost httpPost = new HttpPost("https://api.github.com/graphql");
- httpPost.addHeader("Authorization", "Bearer " + gitHubToken);
- httpPost.addHeader("Accept", "application/json");
- Object returnedObject = null;
-
- try {
- StringEntity entity = new StringEntity(queryObject.toString());
- httpPost.setEntity(entity);
- response = client.execute(httpPost);
-
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- } catch (ClientProtocolException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- BufferedReader bufferedReader = null;
- try {
- bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
- String line;
- StringBuilder stringBuilder = new StringBuilder();
- while ((line = bufferedReader.readLine()) != null) {
-
- stringBuilder.append(line);
- }
-
- String jsonText = stringBuilder.toString();
- Object json = new JSONTokener(jsonText).nextValue(); // gives an object http://stackoverflow.com/questions/14685777/how-to-check-if-response-from-server-is-jsonaobject-or-jsonarray
-
- if (json instanceof JSONObject) {
- JSONObject jsonObject = (JSONObject) json;
- returnedObject = jsonObject;
- } else if (json instanceof JSONArray) {
- JSONArray jsonArray = (JSONArray) json;
- returnedObject = jsonArray;
- }
-
- // System.out.println(stringBuilder.toString());
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
-
- if (bufferedReader != null) {
- bufferedReader.close();
- }
- }
-
- return returnedObject;
- }
-
- /**
- * Reading the blame received for a current selected file name and insert the parent commits of the changed lines,
- * relevant authors and the relevant commits hashes to look for the reviewers of those line ranges
- *
- * @param rootJsonObject JSONObject containing blame information for current selected file
- * @param arrayListOfRelevantChangedLines arraylist containing the changed line ranges of the current selected file
- * @param gettingPr should be true if running this method for finding the authors of buggy lines which are being fixed from the patch
- */
- public void readingTheBlameReceivedForAFile(JSONObject rootJsonObject, ArrayList arrayListOfRelevantChangedLines, boolean gettingPr) {
-
- //running a iterator for fileName arrayList to get the location of the above saved file
- JSONObject dataJSONObject = (JSONObject) rootJsonObject.get("data");
- JSONObject repositoryJSONObect = (JSONObject) dataJSONObject.get("repository");
- JSONObject objectJSONObject = (JSONObject) repositoryJSONObect.get("object");
- JSONObject blameJSONObject = (JSONObject) objectJSONObject.get("blame");
- JSONArray rangeJSONArray = (JSONArray) blameJSONObject.get("ranges");
-
- //getting the starting line no of the range of lines that are modified from the patch
- Iterator arrayListOfRelevantChangedLinesIterator = arrayListOfRelevantChangedLines.iterator(); // iterator for the array list inside the root arraylist
-
- while (arrayListOfRelevantChangedLinesIterator.hasNext()) {
-
- int startingLineNo;
- int endLineNo;
-
- String lineRanges = (String) arrayListOfRelevantChangedLinesIterator.next();
-
- String oldFileRange = StringUtils.substringBefore(lineRanges, "/");
- String newFileRange = StringUtils.substringAfter(lineRanges, "/");
-
- // need to skip the newly created files from taking the blame
- if (oldFileRange.equals("0,0")) {
-
- continue;
-
- }
- //non newly created files
- else {
-
- if (gettingPr) {
- // need to consider the line range in the old file for finding authors and reviewers
-
- startingLineNo = Integer.parseInt(StringUtils.substringBefore(oldFileRange, ","));
- endLineNo = Integer.parseInt(StringUtils.substringAfter(oldFileRange, ","));
-
- } else {
- // need to consider the line range in the new file resulted from applying the commit for finding parent commits
-
- startingLineNo = Integer.parseInt(StringUtils.substringBefore(newFileRange, ","));
- endLineNo = Integer.parseInt(StringUtils.substringAfter(newFileRange, ","));
- }
-
- // as it is required to create a new Map for finding the recent commit for each line range
- Map> mapForStoringAgeAndIndex = new HashMap>();
-
- //checking line by line by iterating the startinLineNo
- while (endLineNo >= startingLineNo) {
- //running through the rangeJSONArray
- for (int i = 0; i < rangeJSONArray.length(); i++) {
- JSONObject rangeJSONObject = (JSONObject) rangeJSONArray.get(i);
- int tempStartingLineNo = (int) rangeJSONObject.get("startingLine");
- int tempEndingLineNo = (int) rangeJSONObject.get("endingLine");
-
- //checking whether the line belongs to that line range group
- if ((tempStartingLineNo <= startingLineNo) && (tempEndingLineNo >= startingLineNo)) {
- // so the relevant startingLineNo belongs in this line range in other words in this JSONObject
- if (!gettingPr) {
- int age = (int) rangeJSONObject.get("age");
- // storing the age field with relevant index of the JSONObject
- mapForStoringAgeAndIndex.putIfAbsent(age, new ArrayList());
- if (!mapForStoringAgeAndIndex.get(age).contains(i)) {
- mapForStoringAgeAndIndex.get(age).add(i); // adding if the index is not present in the array list for the relevant age
- }
-
- } else {
- //for saving the author names of commiters
- JSONObject commitJSONObject = (JSONObject) rangeJSONObject.get("commit");
-
- JSONObject authorJSONObject = (JSONObject) commitJSONObject.get("author");
- String nameOfTheAuthor = (String) authorJSONObject.get("name");
- authorNames.add(nameOfTheAuthor); // authors are added to the Set
-
- String urlOfCommit = (String) commitJSONObject.get("url");
- String commitHashForPRReview = StringUtils.substringAfter(urlOfCommit, "commit/");
- commitHashObtainedForPRReview.add(commitHashForPRReview);
- }
- break;
- } else {
- continue;
- }
- }
- startingLineNo++; // to check for other line numbers
- }
-
- //for the above line range getting the lastest commit which modified the lines
- if (!gettingPr) {
- //converting the map into a treeMap to get it ordered
- TreeMap> treeMap = new TreeMap<>(mapForStoringAgeAndIndex);
- int minimumKeyOfMapForStoringAgeAndIndex = treeMap.firstKey(); // getting the minimum key
- // getting the relevant JSONObject indexes which consists of the recent commit with in the relevant line range
- ArrayList indexesOfJsonObjectForRecentCommit = mapForStoringAgeAndIndex.get(minimumKeyOfMapForStoringAgeAndIndex);
- Iterator indexesOfJsonObjectForRecentCommitIterator = indexesOfJsonObjectForRecentCommit.iterator();
-
- while (indexesOfJsonObjectForRecentCommitIterator.hasNext()) {
- int index = (int) indexesOfJsonObjectForRecentCommitIterator.next();
- // this is the range where the code gets actually modified
- JSONObject rangeJSONObject = (JSONObject) rangeJSONArray.get(index);
- JSONObject commitJSONObject = (JSONObject) rangeJSONObject.get("commit");
- JSONObject historyJSONObject = (JSONObject) commitJSONObject.get("history");
- JSONArray edgesJSONArray = (JSONArray) historyJSONObject.get("edges");
-
- //getting the second json object from the array as it contain the commit of the parent which modified the above line range
- JSONObject edgeJSONObject = (JSONObject) edgesJSONArray.get(1);
- JSONObject nodeJSONObject = (JSONObject) edgeJSONObject.get("node");
- String urlOfTheParentCommit = (String) nodeJSONObject.get("url"); // this contain the URL of the parent commit
- String commitHash = (String) StringUtils.substringAfter(urlOfTheParentCommit, "commit/");
- commitHashesOfTheParent.add(commitHash);
- }
- }
- }
- }
- }
-
- /**
- * Finding the authors of the commits
- *
- * @param owner owner of the repository
- * @param repositoryName repository name
- * @param fileName name of the file which is required to get blame details
- * @param arrayListOfRelevantChangedLines arraylist containing the changed line ranges of the current selected file
- * @param gitHubToken github token for accessing github GraphQL API
- */
- public void iteratingOverForFindingAuthors(String owner, String repositoryName, String fileName, ArrayList arrayListOfRelevantChangedLines, String gitHubToken) {
-
- // calling the graphql api to get the blame details of the current file for the parent commits (That is found by filtering in the graqhql output)
- Iterator commitHashOfTheParentIterator = commitHashesOfTheParent.iterator();
- while (commitHashOfTheParentIterator.hasNext()) {
- String parentCommitHashForCallingGraphQl = (String) commitHashOfTheParentIterator.next();
- graphqlApiJsonObject.put("query", "{repository(owner:\"" + owner + "\",name:\"" + repositoryName + "\"){object(expression:\"" + parentCommitHashForCallingGraphQl + "\"){ ... on Commit{blame(path:\"" + fileName + "\"){ranges{startingLine endingLine age commit{ url author { name email } } } } } } } }");
- JSONObject rootJsonObject = null;
- try {
- rootJsonObject = (JSONObject) callingGraphQl(graphqlApiJsonObject, gitHubToken);
- readingTheBlameReceivedForAFile(rootJsonObject, arrayListOfRelevantChangedLines, true);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-}
-
-
diff --git a/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/MainClass.java b/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/MainClass.java
deleted file mode 100644
index 800da18..0000000
--- a/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/MainClass.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.wso2.code.quality.matrices;
-
-import org.json.JSONArray;
-
-import java.util.Set;
-
-/**
- * This is the class having the main method of this application
- * PMT Access token, patch id and github access token
- * should be passed as command line arguments when running the application
- */
-public class MainClass {
- public static void main(String[] args) {
-
- String pmtToken = args[0];
- String patchId = args[1];
-
- String pmtUrl = "http://umt.private.wso2.com:9765/codequalitymatricesapi/1.0.0//properties?path=/_system/governance/patchs/" + patchId;
-
- RestApiCaller restApiCaller = new RestApiCaller();
- JSONArray jsonArray = (JSONArray) restApiCaller.callingTheAPI(pmtUrl, pmtToken, false, false);
-
- Pmt pmt = new Pmt();
- String[] commitsInTheGivenPatch = pmt.getThePublicGitCommitId(jsonArray);
-
- String gitHubToken = args[2];
-
- BlameCommit blameCommit = new BlameCommit();
- Set commitHashObtainedForPRReview = blameCommit.obtainingRepoNamesForCommitHashes(gitHubToken, commitsInTheGivenPatch, restApiCaller);
-
- Reviewers reviewers = new Reviewers();
- reviewers.findingReviewers(commitHashObtainedForPRReview, gitHubToken);
-
-
- }
-
-
-}
diff --git a/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/Pmt.java b/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/Pmt.java
deleted file mode 100644
index 203612a..0000000
--- a/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/Pmt.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.wso2.code.quality.matrices;/*
-* Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* WSO2 Inc. licenses this file to you under the Apache License,
-* Version 2.0 (the "License"); you may not use this file except
-* in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-/**
- * This class is used for obtaining the commit hashes that belongs to the given patch
- */
-
-public class Pmt {
- private String[] patchInformation_svnRevisionpublic;
-
-
- /**
- * getting the commit IDs from the received json response
- *
- * @param jsonArray jsonarray containing the output received from WSO2 PMT for the given patch
- * @return a copy of the array containing the commit hashes that belongs to the given patch
- */
-
- public String[] getThePublicGitCommitId(JSONArray jsonArray) {
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject jsonObject = (JSONObject) jsonArray.get(i);
- String tempName = (String) jsonObject.get("name");
- if (tempName.equals("patchInformation_svnRevisionpublic")) {
- JSONArray tempCommitsJSONArray = (JSONArray) jsonObject.get("value");
- //initializing the patchInformation_svnRevisionpublic array
- patchInformation_svnRevisionpublic = new String[tempCommitsJSONArray.length()];
- for (int j = 0; j < tempCommitsJSONArray.length(); j++) {
- patchInformation_svnRevisionpublic[j] = ((String) tempCommitsJSONArray.get(j)).trim(); // for ommiting the white spaces at the begingin and end of the commits
- }
- System.out.println("The commit Ids are");
- // for printing all the commits ID associated with a patch
- for (String tmp : patchInformation_svnRevisionpublic) {
- System.out.println(tmp);
- }
- System.out.println();
- break;
- }
- }
- //to prevent from internaal representation by returning referecnce to mutable object
- String clonedPatchInformation_svnRevisionpublic[] = patchInformation_svnRevisionpublic.clone();
- return clonedPatchInformation_svnRevisionpublic;
- }
-}
diff --git a/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/RestApiCaller.java b/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/RestApiCaller.java
deleted file mode 100644
index 54c8a7b..0000000
--- a/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/RestApiCaller.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) Jan 31, 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package com.wso2.code.quality.matrices;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.json.JSONTokener;
-import org.json.JSONObject;
-import org.json.JSONArray;
-
-/**
- * This class is used to call the REST API of both WSO2 PMT and github.com
- */
-
-public class RestApiCaller {
- /**
- * calling the relevant API and saving the output to a file
- *
- * @param URL url of the REST API to be called
- * @param token either the WSO2 PMT access token or giihub.com access token
- * @param requireCommitHeader should be true for accessing the github commit search API and false otherwise
- * @param requireReviewHeader should be true for accessing the github review API or false otherwise
- */
-
- public Object callingTheAPI(String URL, String token, boolean requireCommitHeader, boolean requireReviewHeader) {
-
- BufferedReader bufferedReader = null;
- CloseableHttpClient httpclient = null;
- CloseableHttpResponse httpResponse = null;
- Object returnedObject = null;
-
- try {
- httpclient = HttpClients.createDefault();
- HttpGet httpGet = new HttpGet(URL);
-
- if (token != null) {
-
- httpGet.addHeader("Authorization", "Bearer " + token); // passing the token for the API call
- }
-
- //as the accept header is needed for the review API since it is still in preview mode
- if (requireReviewHeader) {
- httpGet.addHeader("Accept", "application/vnd.github.black-cat-preview+json");
- }
-
- //as the accept header is needed for accessing commit search API which is still in preview mode
- if (requireCommitHeader) {
- httpGet.addHeader("Accept", "application/vnd.github.cloak-preview");
- }
-
- httpResponse = httpclient.execute(httpGet);
- int responseCode = httpResponse.getStatusLine().getStatusCode(); // to get the response code
-
- switch (responseCode) {
- case 200:
- //success
- bufferedReader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent(), "UTF-8"));
- StringBuilder stringBuilder = new StringBuilder();
- String line;
- while ((line = bufferedReader.readLine()) != null) {
- stringBuilder.append(line);
- }
-
- // creating a JSON object from the response
- String JSONText = stringBuilder.toString();
- Object json = new JSONTokener(JSONText).nextValue(); // gives an object http://stackoverflow.com/questions/14685777/how-to-check-if-response-from-server-is-jsonaobject-or-jsonarray
-
- if (json instanceof JSONObject) {
- JSONObject jsonObject = (JSONObject) json;
- returnedObject = jsonObject;
- } else if (json instanceof JSONArray) {
- JSONArray jsonArray = (JSONArray) json;
- returnedObject = jsonArray;
- }
- break;
- case 401:
- // to handle Response code 401: Unauthorized
- System.err.print("Response code 401 : Git hub access token is invalid");
- try {
-
- Thread.sleep(100);
- runningTheAppAgain();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- break;
- case 403:
- // to handle invalid credentials
- System.err.println("Response Code:403 Invalid Credentials, insert a correct token");
- try {
-
- Thread.sleep(100);
- runningTheAppAgain();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- break;
- case 404:
- // to handle invalid patch
- System.err.println("Reponse Code 404: Patch not found, enter a valid patch");
- try {
- Thread.sleep(100);
- runningTheAppAgain();
-
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- break;
- default:
- returnedObject = null;
- }
- } catch (ClientProtocolException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
-
- if (bufferedReader != null) {
- try {
- bufferedReader.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- if (httpResponse != null) {
- try {
- httpResponse.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- if (httpclient != null) {
- try {
- httpclient.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- return returnedObject;
- }
-
- /**
- * this method calls the main method again when incorrect inputs are supplied
- */
- public void runningTheAppAgain() {
- try {
- MainClass.main(null);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-}
-
-
-
diff --git a/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/Reviewers.java b/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/Reviewers.java
deleted file mode 100644
index 8995b72..0000000
--- a/CodeQualityMatricesProject/src/main/java/com/wso2/code/quality/matrices/Reviewers.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) Feb 20, 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package com.wso2.code.quality.matrices;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.lang3.StringUtils;
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-/**
- * This class is used to find the revierwers of the buggy lines of code
- */
-
-public class Reviewers extends BlameCommit {
-
- String searchPullReqeustAPIUrl;
- String pullRequestReviewAPIUrl;
- Set approvedReviewers = new HashSet(); // to store the reviewed and approved users of the pull requests
- Set commentedReviewers = new HashSet(); // to store the reviewed and commented users of the pull requests
-
- public String getSearchPullReqeustAPI() {
- return searchPullReqeustAPIUrl;
- }
-
- /**
- * Sets the URL for Github Search API
- *
- * @param commitHashToBeSearched commit hash to be searched used for finding the Pull requests
- */
-
- public void setSearchPullReqeustAPI(String commitHashToBeSearched) {
- this.searchPullReqeustAPIUrl = "https://api.github.com/search/issues?q=" + commitHashToBeSearched;
- }
-
- public String getPullRequestReviewAPIUrl() {
- return pullRequestReviewAPIUrl;
- }
-
- public void setPullRequestReviewAPIUrl(String repoLocation, int pullRequestNumber) {
- this.pullRequestReviewAPIUrl = "https://api.github.com/repos/" + repoLocation + "/pulls/" + pullRequestNumber + "/reviews";
- }
-
- // map for storing the pull requests numbers against their repository
- Map> mapContainingPRNoAgainstRepoName = new HashMap>();
-
- /**
- * for finding the reviewers of each commit and storing them in a Set
- *
- * @param commitHashObtainedForPRReview commit hash Set for finding the pull requests
- * @param githubToken github token for accessing github REST API
- */
- public void findingReviewers(Set commitHashObtainedForPRReview, String githubToken) {
- Iterator commitHashObtainedForPRReviewIterator = commitHashObtainedForPRReview.iterator();
- while (commitHashObtainedForPRReviewIterator.hasNext()) {
- String commitHashForFindingReviewers = (String) commitHashObtainedForPRReviewIterator.next();
- setSearchPullReqeustAPI(commitHashForFindingReviewers);
- // calling the github search API
- JSONObject rootJsonObject = (JSONObject) callingTheAPI(getSearchPullReqeustAPI(), githubToken, false, true);
- // reading thus saved json file
- savingPrNumberAndRepoName(rootJsonObject);
- }
- System.out.println("Done Mapping" + mapContainingPRNoAgainstRepoName);
- savingReviewersToList(githubToken);
- // printing the list of reviewers of pull requests
- printReviewUsers();
- }
-
- /**
- * reads the search API output and save the pull request number with the repo name in a map
- *
- * @param rootJsonObject JSONObject received from github search API
- */
- public void savingPrNumberAndRepoName(JSONObject rootJsonObject) {
- JSONArray itemsJsonArray = (JSONArray) rootJsonObject.get("items");
-
- for (int i = 0; i < itemsJsonArray.length(); i++) {
- JSONObject prJsonObject = (JSONObject) itemsJsonArray.get(i);
- // filtering only the closed repositories
- if (((String) prJsonObject.get("state")).equals("closed")) {
- String repositoryUrl = (String) prJsonObject.get("repository_url");
- String repositoryLocation = StringUtils.substringAfter(repositoryUrl, "https://api.github.com/repos/");
- if (repositoryLocation.contains("wso2/")) {
- // to filter out only the repositories belongs to wso2
- int pullRequetNumber = (int) prJsonObject.get("number");
- mapContainingPRNoAgainstRepoName.putIfAbsent(repositoryLocation, new HashSet()); // put the repo name key only if it does not exists in the map
- mapContainingPRNoAgainstRepoName.get(repositoryLocation).add(pullRequetNumber); // since SET is there we do not need to check for availability of the key in the map
- }
- }
- }
- }
-
- /**
- * Calling the github review API for a selected pull request on its relevant product
- *
- * @param githubToken github token for accessing github REST API
- */
- public void savingReviewersToList(String githubToken) {
-
- for (Map.Entry m : mapContainingPRNoAgainstRepoName.entrySet()) {
- String productLocation = (String) m.getKey();
- @SuppressWarnings("unchecked")
- Set prNumbers = (Set) m.getValue();
- Iterator prNumberIterator = prNumbers.iterator();
- while (prNumberIterator.hasNext()) {
- int prNumber = (int) prNumberIterator.next();
- setPullRequestReviewAPIUrl(productLocation, prNumber);
- JSONArray rootJsonArray = (JSONArray) callingTheAPI(getPullRequestReviewAPIUrl(), githubToken, false, true);
- // for reading the output JSON from above and adding the reviewers to the Set
- readingTheReviewOutJSON(rootJsonArray, productLocation, prNumber);
- }
- }
- }
-
- /**
- * Reading the output received from the review API and saving the relevant reviewers and commented users to a Set
- *
- * @param reviewJsonArray JSON response from the github Review API
- * @param productLocation Product Location for printing the error message when there are no reviewers and a commented users
- * @param prNumber relevant PR number for finding the reviewers and commenters
- */
- public void readingTheReviewOutJSON(JSONArray reviewJsonArray, String productLocation, int prNumber) {
-
- if (reviewJsonArray.length() != 0) {
-
- for (int i = 0; i < reviewJsonArray.length(); i++) {
- JSONObject reviewJsonObject = (JSONObject) reviewJsonArray.get(i);
- if ((reviewJsonObject.get("state")).equals("APPROVED")) {
-
- JSONObject userJsonObject = (JSONObject) reviewJsonObject.get("user");
- String approvedReviwer = (String) userJsonObject.get("login");
- approvedReviewers.add(approvedReviwer); // adding the approved user to the Set
-
- } else if ((reviewJsonObject.get("state")).equals("COMMENTED")) {
- JSONObject userJsonObject = (JSONObject) reviewJsonObject.get("user");
- String commentedReviwer = (String) userJsonObject.get("login");
- commentedReviewers.add(commentedReviwer); // adding the commented user to the Set
- }
- }
- } else {
- System.out.println("There are no records of reviews for pull request: " + prNumber + " on " + productLocation + " repository");
- }
- }
-
- /**
- * Print the list of reviewers and commented users on the pull requests which introduce bugs to the code base
- */
- public void printReviewUsers() {
- System.out.println("Reviewed and approved users of the bug lines: " + approvedReviewers);
- System.out.println("Reviewed and commented users on bug lines: " + commentedReviewers);
- }
-}
diff --git a/CodeQualityMatricesProject/src/test/java/com/wso2/code/quality/matrices/MainClassTest.java b/CodeQualityMatricesProject/src/test/java/com/wso2/code/quality/matrices/MainClassTest.java
deleted file mode 100644
index 0df981b..0000000
--- a/CodeQualityMatricesProject/src/test/java/com/wso2/code/quality/matrices/MainClassTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.wso2.code.quality.matrices;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Unit test for simple MainClass.
- */
-public class MainClassTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public MainClassTest(String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( MainClassTest.class );
- }
-
- /**
- * Rigourous Test :-)
- */
- public void testApp()
- {
- assertTrue( true );
- }
-}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b64ee3b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,48 @@
+# Welcome to Code Quality Metrics
+
+At WSO2 when a customer report a bug on a product, often we have to issue a patch to solve the problem. As part of providing this patch, we also record the commit hashes which fixed the issue in WSO2 Patch Management System. What this program does is, it takes those commit hashes and identify the initial lines which caused the bug to arose, who authored them, reviewed them and approved them. The reason for doing this is to see whether there are any patterns on the bugs introduced to the code. If so, WSO2 can educate the people on relevant patterns and prevent the bugs in future releases.
+
+## Architecture
+Code Quality Metrics application make API calls to WSO2 PMT REST API, Github REST API v3 and Github Graphql API in it’s execution. PMT REST API calls are made to obtain the relevant commit hashes reside in the given patch, Github REST API calls are made to identify the relevant WSO2 repositories containing the obtained commits ( obtained from WSO2 PMT REST API for the given patch), to identify whether those commits are formed from a octopus merge commit, to obtain commit history of a given file, to identify relevant pull requests containing the obtained author commits and to identify relevant reviewers of those pull requests if any.
+
+Since there is no Github REST API yet deployed for obtaining blame details of files, Github Graphql API was used to get the blame details of modified files from above obtained commits, even though the GraphQL API is still in early access mode.
+
+[Github Java API](https://github.com/eclipse/egit-github/tree/master/org.eclipse.egit.github.core) was used for obtaining the modified files and their relevant patch strings for the commits resides on the given patch.
+
+
+
+
+
+
+## Installation
+### Prerequisites
+* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) installed.
+* [Java](http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html) installed.
+* [Apache Maven](https://maven.apache.org/download.cgi) installed.
+
+After cloning or downloading the repository open `Eclipse IDE` or `IntelliJ IDEA` and open project’s `pom.xml`(Import all the dependencies if required).
+
+## Running Samples
+It is required to provide the relevant WSO2 patch name as a command line argument to obtain relevant authors and reviewers of code lines been modified from the given patch.
+
+Run following samples and check with outputs,
+
+1. WSO2-CARBON-PATCH-4.4.0-0680
+ Authors : [Lakmali, Amila De Silva, lalaji, Chamila]
+ Approved Users: []
+ Commented Users:[]
+
+ Note : Since this is an old patch reviewers of bug lines are not present as github protected branch feature was used by WSO2 from 2017 onwards.
+2. WSO2-CARBON-PATCH-4.4.0-1134
+ Authors: []
+ Approved Users: []
+ Commented Users: []
+
+ Note : Since this patch only introduce new files to the repository, no authors of bug lines are shown.
+
+3. WSO2-CARBON-PATCH-4.4.0-1102
+ Authors: [nuwandiw, Pasindu Nivanthaka Tennage, godwin]
+ Approved Users: [darshanasbg]
+ Commented Users: []
+
+ Note: Since this patch has modified lines added after enabling protected branch feature on master branches, the application provides the approved user of the bug lines as “darshanasbg” and there are no commented users on those lines.
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..aa97456
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,131 @@
+
+
+
+ 4.0.0
+
+
+ org.wso2
+ wso2
+ 5
+
+
+ org.wso2.code-quality-metrics
+ code-quality-metrics
+ 1.0.0-SNAPSHOT
+ jar
+ code-quality-metrics
+ http://maven.apache.org
+
+
+ 1.8
+ UTF-8
+ 4.12
+ 1.2.17
+ 20160810
+ 2.8.0
+ 2.1.5
+ 1.1.1
+ 4.5.2
+ 3.5
+ 1.3
+ 2.4
+
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+ org.hamcrest
+ hamcrest-core
+
+
+
+
+ org.hamcrest
+ hamcrest-library
+ ${org.hamcrest.version}
+ test
+
+
+ log4j
+ log4j
+ ${log4j.version}
+
+
+ org.json
+ json
+ ${org.json.version}
+
+
+ com.google.code.gson
+ gson
+ ${com.google.code.gson.version}
+
+
+ org.eclipse.mylyn.github
+ org.eclipse.egit.github.core
+ ${org.eclipse.mylyn.github.version}
+
+
+ org.apache.httpcomponents
+ httpclient
+ ${org.apache.httpcomponents.version}
+
+
+ com.googlecode.json-simple
+ json-simple
+ ${com.googlecode.json-simple.version}
+
+
+ org.apache.commons
+ commons-lang3
+ ${org.apache.commons.version}
+
+
+ org.apache.directory.studio
+ org.apache.commons.io
+ ${org.apache.directory.studio.version}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.1
+
+
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.16
+
+
+
+
diff --git a/src/main/java/com/wso2/code/quality/metrics/ApiUtility.java b/src/main/java/com/wso2/code/quality/metrics/ApiUtility.java
new file mode 100644
index 0000000..ef3d6d5
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/ApiUtility.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+import com.wso2.code.quality.metrics.exceptions.CodeQualityMetricsException;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.log4j.Logger;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * Utility class for calling APIs.
+ *
+ * @since 1.0.0
+ */
+public final class ApiUtility {
+ private static final Logger logger = Logger.getLogger(ApiUtility.class);
+
+ // to prevent instantiation
+ private ApiUtility() {
+ }
+
+ /**
+ * Used for calling the REST APIs.
+ *
+ * @param httpGet Instance of the relevant httpGet
+ * @return String representation of the json response
+ * @throws CodeQualityMetricsException results
+ */
+ public static String callApi(HttpGet httpGet) throws CodeQualityMetricsException {
+ String jsonText;
+ try (CloseableHttpClient httpClient = HttpClients.createDefault();
+ CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) {
+ int responseCode = httpResponse.getStatusLine().getStatusCode();
+ if (responseCode == 200) {
+ //success
+ try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpResponse.getEntity()
+ .getContent(), StandardCharsets.UTF_8))) {
+ StringBuilder stringBuilder = new StringBuilder();
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ stringBuilder.append(line);
+ }
+ // creating a JSON object from the response
+ jsonText = stringBuilder.toString();
+ }
+ } else {
+ throw new CodeQualityMetricsException("Error occurred while calling the API, the response code is " +
+ responseCode);
+ }
+ } catch (ClientProtocolException e) {
+ throw new CodeQualityMetricsException("ClientProtocolException when calling the REST API", e);
+ } catch (NullPointerException e) {
+ // thrown from both getStatusLine() and getEntity() method on httpResponse object
+ throw new CodeQualityMetricsException(e.getMessage(), e.getCause());
+ } catch (IOException e) {
+ throw new CodeQualityMetricsException("IOException occurred when calling the REST API", e);
+ }
+ return jsonText;
+ }
+
+ /**
+ * Used for calling the github graphql API.
+ *
+ * @param httpPost relevant instance of the httpost
+ * @return String representation of the json response
+ * @throws CodeQualityMetricsException results
+ */
+ public static String callGraphQlApi(HttpPost httpPost) throws CodeQualityMetricsException {
+ String jsonText;
+ try (CloseableHttpClient httpClient = HttpClients.createDefault();
+ CloseableHttpResponse httpResponse = httpClient.execute(httpPost)) {
+ int responseCode = httpResponse.getStatusLine().getStatusCode();
+ if (responseCode == 200) {
+ try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpResponse.getEntity()
+ .getContent(), StandardCharsets.UTF_8))) {
+ String line;
+ StringBuilder stringBuilder = new StringBuilder();
+ while ((line = bufferedReader.readLine()) != null) {
+ stringBuilder.append(line);
+ }
+ jsonText = stringBuilder.toString();
+ logger.debug("The response received from the Github GraphQL converted to a JSON text successfully");
+ }
+ } else {
+ throw new CodeQualityMetricsException("Error occurred while calling the graphQL API, the response " +
+ "code is " + responseCode);
+ }
+ } catch (UnsupportedEncodingException e) {
+ throw new CodeQualityMetricsException("Encoding error occurred before calling the github graphQL API", e);
+ } catch (ClientProtocolException e) {
+ throw new CodeQualityMetricsException("Client protocol exception occurred when calling the github" +
+ " graphQL API", e);
+ } catch (IOException e) {
+ throw new CodeQualityMetricsException("A problem or the connection was aborted while executing the" +
+ " httpPost", e);
+ }
+ return jsonText;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/Application.java b/src/main/java/com/wso2/code/quality/metrics/Application.java
new file mode 100644
index 0000000..aa6d7ce
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/Application.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+import org.apache.log4j.Logger;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.Properties;
+
+/**
+ * Class having the main method of this application
+ * PMT Access token, patch id and github access token
+ * should be passed in order as command line arguments when running the application.
+ *
+ * @since 1.0.0
+ */
+public class Application {
+ private static final Logger logger = Logger.getLogger(Application.class);
+
+ public static void main(String[] args) {
+ if (args.length == 1) {
+ String patchId = args[0];
+ Properties defaultProperties = new Properties();
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ try (InputStream inputStream = classLoader.getResourceAsStream("tokens.properties")) {
+ defaultProperties.load(inputStream);
+ byte[] pmtTokenInBytes = Base64.getDecoder().decode(defaultProperties.getProperty("pmtToken"));
+ String pmtToken = new String(pmtTokenInBytes, StandardCharsets.UTF_8);
+ byte[] githubTokenInBytes = Base64.getDecoder().decode(defaultProperties.getProperty("githubToken"));
+ String githubToken = new String(githubTokenInBytes, StandardCharsets.UTF_8);
+ CodeQualityMetricsExecutor codeQualityMetricsExecutor = new CodeQualityMetricsExecutor(pmtToken,
+ patchId, githubToken);
+ codeQualityMetricsExecutor.execute();
+ } catch (IOException e) {
+ logger.error("IO exception occurred when loading the inputstream to the " +
+ "properties object", e);
+ }
+ } else {
+ logger.error("Incorrect command line arguments were given");
+ logger.debug("Please enter only the required patch id as the command line argument to initiate the " +
+ "program");
+ }
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/ChangesFinder.java b/src/main/java/com/wso2/code/quality/metrics/ChangesFinder.java
new file mode 100644
index 0000000..105743c
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/ChangesFinder.java
@@ -0,0 +1,371 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
+import com.google.gson.reflect.TypeToken;
+import com.wso2.code.quality.metrics.exceptions.CodeQualityMetricsException;
+import com.wso2.code.quality.metrics.model.CommitHistoryApiResponse;
+import com.wso2.code.quality.metrics.model.GraphQlResponse;
+import com.wso2.code.quality.metrics.model.Graphql;
+import com.wso2.code.quality.metrics.model.SearchApiResponse;
+import com.wso2.code.quality.metrics.model.SingleCommitApiResponse;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+import org.json.JSONObject;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+/**
+ * Used for getting the blame information on relevant changed line ranges on relevant files from the
+ * given patch.
+ *
+ * @since 1.0.0
+ */
+
+public class ChangesFinder {
+ private static final Logger logger = Logger.getLogger(ChangesFinder.class);
+
+ private Set authorNames = new HashSet<>(); //authors of the bug lines fixed from the patch
+ private Set authorCommits = new HashSet<>(); // author commits of the bug lines fixed from the patch
+ private final JSONObject jsonStructure = new JSONObject();
+ private final Gson gson = new Gson();
+
+ /**
+ * Used to prevent SIC_INNER_SHOULD_BE_STATIC_ANON error that comes when building with WSO2 parent
+ * pom, as suggested by the above error an static inner class is used to prevent the error.
+ */
+ private static class ListType extends TypeToken> {
+ }
+
+ /**
+ * Used for obtaining the repositories that contain the relevant commits belongs to the given patch.
+ *
+ * @param gitHubToken github token for accessing github API
+ * @param commitHashes List of commits that belongs to the given patch
+ * @return author commits of the bug lines which are fixed from the given patch
+ */
+ Set obtainRepoNamesForCommitHashes(String gitHubToken, List commitHashes) {
+ commitHashes.forEach(commitHash -> {
+ try {
+ String jsonText = GithubApiCallerUtils.callSearchCommitApi(commitHash, gitHubToken);
+ List repoLocations = saveRepoNames(jsonText);
+ identifyChangedFile(repoLocations, commitHash, gitHubToken);
+ } catch (CodeQualityMetricsException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ });
+ return authorCommits;
+ }
+
+ /**
+ * Use to save the relevant repository names that contain the given commit hash to a List.
+ *
+ * @param jsonText String representation of the json response
+ * @return A list of repository locations having the given commit hash
+ * @throws CodeQualityMetricsException Resulted Code Quality Metrics Exception
+ */
+ private List saveRepoNames(String jsonText) throws CodeQualityMetricsException {
+ List repoLocation = new ArrayList<>();
+ SearchApiResponse searchCommitPojo;
+ try {
+ searchCommitPojo = gson.fromJson(jsonText, SearchApiResponse.class);
+ } catch (JsonSyntaxException e) {
+ throw new CodeQualityMetricsException(e.getMessage(), e.getCause());
+ }
+ searchCommitPojo.getContainingRepositories()
+ .forEach(recordItem -> repoLocation.add(recordItem.getRepository().getRepositoryLocation()));
+ logger.debug("Repositories having the given commit are successfully saved in an List");
+ return repoLocation;
+ }
+
+ /**
+ * Used to identify the file changed and their relevant line ranges changed in selected repository from the given
+ * commit hash.
+ *
+ * @param repoLocation List of repository locations having the given commit hash
+ * @param commitHash commit hash to be searched for containing WSO2 repositories
+ * @param gitHubToken Github access token for accessing github API
+ */
+ private void identifyChangedFile(List repoLocation, String commitHash, String gitHubToken) {
+ SdkGitHubClient sdkGitHubClient = new SdkGitHubClient(gitHubToken);
+ repoLocation.stream()
+ .filter(repositoryName -> StringUtils.contains(repositoryName, "wso2/"))
+ .forEach(repositoryName -> {
+ Map fileNamesWithPatchString;
+ tryBlock:
+ try {
+ fileNamesWithPatchString = sdkGitHubClient.getFilesChanged(repositoryName, commitHash);
+ Map> fileNamesWithDeletedLineNumbers = new HashMap<>();
+ Map fileNamesWithPreviousCommitHash = new HashMap<>();
+ if (fileNamesWithPatchString.isEmpty()) {
+ break tryBlock;
+ }
+ /* looping from one file to file and saving deleted lines against the file name in another
+ map */
+ fileNamesWithPatchString.forEach((fileName, patchString) -> {
+ Set deletedLines = identifyDeletedLines(patchString);
+ String previousCommitHashOfFile;
+ //for omitting files without having deleted lines in other words newly created files
+ if (deletedLines.size() > 0) {
+ fileNamesWithDeletedLineNumbers.put(fileName, deletedLines);
+ previousCommitHashOfFile = checkForOctopusMerge(repositoryName, fileName,
+ commitHash, gitHubToken);
+ if (previousCommitHashOfFile != null && !previousCommitHashOfFile.isEmpty()) {
+ fileNamesWithPreviousCommitHash.put(fileName, previousCommitHashOfFile);
+ } else {
+ logger.warn("The changes from " + commitHash + " on " + fileName + " file " +
+ "may have been reversed from another commit on the same PR, so " +
+ "commit " + commitHash + " does not appear in history of current " +
+ "file due to git's history simplification when listing history");
+ }
+ } else {
+ logger.debug(fileName + " filename is a newly created file");
+ }
+ });
+ getBlameDetails(repositoryName, fileNamesWithPreviousCommitHash,
+ fileNamesWithDeletedLineNumbers, gitHubToken);
+ } catch (CodeQualityMetricsException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ });
+ if (logger.isDebugEnabled()) {
+ logger.debug("\n Author names :" + authorNames);
+ logger.debug("\n Author commits :" + authorCommits);
+ }
+ }
+
+ /**
+ * Used to check whether the commit in the given patch is an octopuss commit or not, if it is octopuss commit an
+ * exception is thrown as the current scope of the program does not support octopus commits.
+ *
+ * @param repositoryName current selected Repository
+ * @param filePath current selected file name
+ * @param latestCommitHash current selected recent commit contained in the given patch
+ * @param githubToken github access token for accessing github REST API
+ * @return the commit hash returned from findPreviousCommitOfFile method
+ */
+ private String checkForOctopusMerge(String repositoryName, String filePath, String latestCommitHash, String
+ githubToken) {
+ String previousCommitOfFile = null;
+ try {
+ // need check whether the given commit has more than 2 parent commits
+ String singleCommitJsonText = GithubApiCallerUtils.callSingleCommitApi(repositoryName, latestCommitHash,
+ githubToken);
+ SingleCommitApiResponse singleCommitApiResponse = gson.fromJson(singleCommitJsonText,
+ SingleCommitApiResponse.class);
+ if (singleCommitApiResponse.getParentCommits().size() == 1) {
+ /*if the singleCommitApiResponse.getParentCommits().size() == 1 it is fast forward merge, so no need
+ to change the latestCommitHash*/
+ if (logger.isDebugEnabled()) {
+ logger.debug("The commit " + latestCommitHash + " in relevant patch is not a octopuss merge " +
+ "commit");
+ }
+ } else if (singleCommitApiResponse.getParentCommits().size() == 2) {
+ latestCommitHash = singleCommitApiResponse.getParentCommits().get(1).getCommitHash();
+ if (logger.isDebugEnabled()) {
+ logger.debug("The commit " + latestCommitHash + " in relevant patch is not a octopuss merge " +
+ "commit");
+ }
+ } else if (singleCommitApiResponse.getParentCommits().size() > 2) {
+ throw new CodeQualityMetricsException("The commit " + latestCommitHash + " in relevant patch is " +
+ "an octopuss merge commit, octopuss merge commits are avoided in the current scope of " +
+ "the program");
+ }
+ previousCommitOfFile = findPreviousCommitOfFile(repositoryName, filePath, latestCommitHash, githubToken);
+ } catch (CodeQualityMetricsException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ return previousCommitOfFile;
+ }
+
+ /**
+ * Used to get the previous commit hash of the selected file before the current selected commit which
+ * contained in the given patch.
+ *
+ * @param repositoryName current selected Repository
+ * @param filePath current selected file name
+ * @param latestCommitHash current selected recent commit contained in the given patch
+ * @param githubToken github access token for accessing github REST API
+ * @return commits hash prior to the current selected commit hash contained in the given patch of the current
+ * selected file
+ */
+ private String findPreviousCommitOfFile(String repositoryName, String filePath, String latestCommitHash,
+ String githubToken) {
+ String previousCommitOfFile = null;
+ Map commitWithDate = new HashMap<>();
+ try {
+ String commitHistoryJsonText = GithubApiCallerUtils.callCommitHistoryApi(repositoryName, filePath,
+ githubToken);
+ Type listType = new ListType().getType();
+ List commitHistoryApiResponses = gson.fromJson(commitHistoryJsonText,
+ listType);
+ commitHistoryApiResponses.forEach(commitHistoryApiResponse -> {
+ String commitHash = commitHistoryApiResponse.getCommitHash();
+ String date = commitHistoryApiResponse.getCommit().getAuthor().getDate();
+ commitWithDate.put(commitHash, date);
+ });
+ String latestCommitDate = commitWithDate.get(latestCommitHash);
+ if (latestCommitDate != null && !latestCommitDate.isEmpty()) {
+ String previousCommitDate = getPreviousCommitDate(commitWithDate, latestCommitDate);
+ // looping for finding the commit Hash introduced in previous commit date
+ for (Map.Entry entry : commitWithDate.entrySet()) {
+ if (entry.getValue().equals(previousCommitDate)) {
+ previousCommitOfFile = (String) entry.getKey();
+ }
+ }
+ } else {
+ return null;
+ /*the changes from given commit to the current selected file may have been reversed from another commit,
+ so the given commit does not appear in history of the current file due to git's history simplification
+ when listing history*/
+ }
+ } catch (CodeQualityMetricsException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ return previousCommitOfFile;
+ }
+
+ /**
+ * Used to get the previous commit date of the selected file before the current commit by sorting the
+ * commit dates.
+ *
+ * @param commitWithDate map contating all the commits with their respective date of the current selected
+ * file
+ * @param latestCommitDate latest commit date of the current selected file
+ * @return previous commit date of the current selected file
+ */
+ private String getPreviousCommitDate(Map commitWithDate, String latestCommitDate) {
+ //creating a temporary list for sorting the date in ascending order
+ List sortedCommitDates = new ArrayList<>(commitWithDate.values());
+ Collections.sort(sortedCommitDates);
+ int indexOfLatestcommit = sortedCommitDates.indexOf(latestCommitDate);
+ return sortedCommitDates.get(--indexOfLatestcommit);
+ }
+
+ /**
+ * Used to obtain the blame details of files for their previous commits.
+ *
+ * @param repoLocation current selected Repository
+ * @param fileNamesWithPreviousCommitHash map containing changed files with their prior commit hashes
+ * @param fileNamesWithDeletedLineNumbers map containing changed files with their deleted line numbers
+ * @param githubToken github access token for accessing github REST API
+ */
+ private void getBlameDetails(String repoLocation, Map fileNamesWithPreviousCommitHash,
+ Map> fileNamesWithDeletedLineNumbers, String githubToken) {
+ // filtering the owner and the repository name from the repoLocation
+ String owner = StringUtils.substringBefore(repoLocation, "/");
+ String repositoryName = StringUtils.substringAfter(repoLocation, "/");
+ Graphql graphqlBean = new Graphql();
+ fileNamesWithPreviousCommitHash.forEach((fileName, previousCommitHash) -> {
+ graphqlBean.setGraphqlInputWithoutHistory(owner, repositoryName, previousCommitHash, fileName);
+ jsonStructure.put("query", graphqlBean.getGraphqlInputWithoutHistory());
+ String jsonText;
+ try {
+ // calling the graphql API for getting blame information for the current file.
+ jsonText = GithubApiCallerUtils.callGraphqlApi(jsonStructure, githubToken);
+ findAuthorCommits(jsonText, fileNamesWithDeletedLineNumbers, fileName);
+ } catch (CodeQualityMetricsException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ });
+ }
+
+ /**
+ * Used to save the authors and relevant author commits of the buggy lines of code which are been fixed by
+ * the given patch, to relevant lists.
+ *
+ * @param jsonText String representation of the json response received from github graphql
+ * API
+ * @param fileNamesWithDeletedLineNumbers map containing changed files with their deleted line numbers
+ * @param selectedFileName selected file for finding the authors and author commits of its buggy
+ * lines
+ */
+ private void findAuthorCommits(String jsonText, Map> fileNamesWithDeletedLineNumbers, String
+ selectedFileName) {
+ GraphQlResponse graphQlResponse = gson.fromJson(jsonText, GraphQlResponse.class);
+ Set deletedLines = fileNamesWithDeletedLineNumbers.get(selectedFileName);
+ deletedLines.forEach(deletedLineNumber ->
+ graphQlResponse.getResponse().getRepository().getFile().getBlame().getRanges()
+ .stream()
+ .filter(graphqlRange -> (graphqlRange.getStartingLine() <= deletedLineNumber &&
+ graphqlRange.getEndingLine() >= deletedLineNumber))
+ .forEach(graphqlRange -> {
+ String authorName = graphqlRange.getCommit().getAuthor().getName();
+ String authorcommit = StringUtils.substringAfter(graphqlRange.getCommit().getUrl(),
+ "commit/");
+ authorNames.add(authorName); // authors are added to the Set
+ authorCommits.add(authorcommit); // author commits are added to the set
+ }));
+ }
+
+ /**
+ * Used to identify the deleted lines in the selected file from the current selected commit in given patch.
+ *
+ * @param patchString patch string of the selected file received from github SDK
+ * @return a Set of deleted lines in the above mentioned file
+ */
+ private Set identifyDeletedLines(String patchString) {
+ Set linesDeletedInSelectedFile = new HashSet<>();
+ Pattern pattern = Pattern.compile("@@ -");
+ String patches[] = pattern.split(patchString);
+ for (String patchRange : patches) {
+ Scanner scanner = new Scanner(patchRange);
+ int lineNumber = 0;
+ //for finding the starting line number of the modified range.
+ if (scanner.hasNext()) {
+ String patchLine = scanner.nextLine();
+ String words[] = patchLine.split(",");
+ //String at the first index of word array is the starting line number of the modified range
+ lineNumber = Integer.parseInt(words[0]);
+ }
+ //for finding the deleted lines in the string
+ while (scanner.hasNext()) {
+ String patchLine = scanner.nextLine();
+ String words[];
+ //to differentiate completely empty lines ("") and empty lines with spaces and tabs
+ if (patchLine.trim().length() != 0) {
+ words = patchLine.split("\\s");
+ } else {
+ words = patchLine.trim().split("\\s");
+ }
+ String sign = words[0];
+ // lines starting with "+" are neglected as they are newly introduced lines from the given commit
+ if ("-".equals(sign) || "".equals(sign)) {
+ if ("-".equals(sign)) {
+ //lines starting with "-" are the modified lines in the old file
+ linesDeletedInSelectedFile.add(lineNumber);
+ }
+ lineNumber++;
+ }
+ }
+ }
+ return linesDeletedInSelectedFile;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/CodeQualityMetricsExecutor.java b/src/main/java/com/wso2/code/quality/metrics/CodeQualityMetricsExecutor.java
new file mode 100644
index 0000000..74e8810
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/CodeQualityMetricsExecutor.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+import com.google.gson.Gson;
+import com.wso2.code.quality.metrics.exceptions.CodeQualityMetricsException;
+import org.apache.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static com.wso2.code.quality.metrics.model.Constants.COMMITS_INSIDE_GIVEN_PATCH;
+
+/**
+ * Used for executing the program.
+ *
+ * @since 1.0.0
+ */
+public class CodeQualityMetricsExecutor {
+ private static final Logger logger = Logger.getLogger(CodeQualityMetricsExecutor.class);
+
+ private final String pmtToken;
+ private final String patchId;
+ private final String gitHubToken;
+
+ /**
+ * Used to create an instance of CodeQualityMetricsExecutor class.
+ *
+ * @param pmtToken PMT Access Token
+ * @param patchId Patch ID
+ * @param gitHubToken Github access token
+ */
+ public CodeQualityMetricsExecutor(String pmtToken, String patchId, String gitHubToken) {
+ this.pmtToken = pmtToken;
+ this.patchId = patchId;
+ this.gitHubToken = gitHubToken;
+ }
+
+ /**
+ * The entry point to Code Quality Metrics application.
+ */
+ public void execute() {
+ try {
+ List commitHashes = findCommitHashesInPatch();
+ ChangesFinder changesFinder = new ChangesFinder();
+ Set authorCommits = changesFinder.obtainRepoNamesForCommitHashes(gitHubToken, commitHashes);
+ ReviewAnalyser reviewAnalyser = new ReviewAnalyser();
+ reviewAnalyser.findReviewers(authorCommits, gitHubToken);
+ reviewAnalyser.printReviewUsers();
+ logger.debug("The application executed successfully");
+ } catch (CodeQualityMetricsException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ }
+
+ /**
+ * Used to filter out the commit hashes that belongs to the given patch.
+ *
+ * @return List of commit hashes contained in the given patch
+ */
+ List findCommitHashesInPatch() throws CodeQualityMetricsException {
+ PmtApiCaller pmtApiCaller = new PmtApiCaller();
+ String jsonText;
+ List commitHashes = new ArrayList<>();
+ try {
+ jsonText = pmtApiCaller.callApi(pmtToken, patchId);
+ } catch (CodeQualityMetricsException e) {
+ throw new CodeQualityMetricsException("Error occurred while calling PMT API", e);
+ }
+ Gson gson = new Gson();
+ List pmtResponse = gson.fromJson(jsonText, List.class);
+ for (Object pmtEntry : pmtResponse) {
+ if (pmtEntry instanceof Map) {
+ @SuppressWarnings("unchecked")
+ Map entryMap = (Map) pmtEntry;
+ if (COMMITS_INSIDE_GIVEN_PATCH.equals(entryMap.get("name"))) {
+ commitHashes = (List) entryMap.get("value");
+ //to avoid leading and trailing white spaces in commit hashes
+ commitHashes.replaceAll(String::trim);
+ }
+ }
+ }
+ if (logger.isDebugEnabled()) {
+ logger.error("The commit hashes are: " + commitHashes);
+ }
+ return commitHashes;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/GithubApiCallerUtils.java b/src/main/java/com/wso2/code/quality/metrics/GithubApiCallerUtils.java
new file mode 100644
index 0000000..0fe5033
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/GithubApiCallerUtils.java
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+import com.wso2.code.quality.metrics.exceptions.CodeQualityMetricsException;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.json.JSONObject;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Properties;
+
+import static com.wso2.code.quality.metrics.model.Constants.ACCEPT;
+import static com.wso2.code.quality.metrics.model.Constants.AUTHORIZATION;
+import static com.wso2.code.quality.metrics.model.Constants.BEARER;
+
+/**
+ * Utility class used for all github communications.
+ *
+ * @since 1.0.0
+ */
+public final class GithubApiCallerUtils {
+ private static final Properties defaultProperties = new Properties();
+ private static final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+ /**
+ * To prevent instantiation from other classes
+ */
+ private GithubApiCallerUtils() {
+ }
+
+ /**
+ * Used for calling the github search REST API.
+ *
+ * @param commitHash commit hash to be searched
+ * @param githubAccessToken Github access token for accessing github API
+ * @return String representation of the json response
+ * @throws CodeQualityMetricsException results
+ */
+ public static String callSearchCommitApi(String commitHash, String githubAccessToken) throws
+ CodeQualityMetricsException {
+ HttpGet httpGet;
+ try (InputStream inputStream = classLoader.getResourceAsStream("url.properties")) {
+ defaultProperties.load(inputStream);
+ String url = defaultProperties.getProperty("searchCommitApiUrl") + commitHash;
+ httpGet = new HttpGet(url);
+ httpGet.addHeader(AUTHORIZATION, BEARER + githubAccessToken);
+ //as the accept header is needed for accessing commit search API which is still in preview mode
+ httpGet.addHeader(ACCEPT, defaultProperties.getProperty("searchCommitApiHeader"));
+ } catch (IllegalArgumentException e) {
+ throw new CodeQualityMetricsException("The url provided for accessing the Github Search Commit API is " +
+ "invalid ", e);
+ } catch (IOException e) {
+ throw new CodeQualityMetricsException("IO exception occurred when loading the inputstream to the " +
+ "properties object", e);
+ }
+ return ApiUtility.callApi(httpGet);
+ }
+
+ /**
+ * Used to call github commit REST API.
+ *
+ * @param repoLocation repository location
+ * @param filePath location of the file
+ * @param githubAccessToken Github access token for accessing github API
+ * @return String representation of the json response
+ * @throws CodeQualityMetricsException Resulted Code Quality Metrics Exception
+ */
+ public static String callCommitHistoryApi(String repoLocation, String filePath, String githubAccessToken)
+ throws CodeQualityMetricsException {
+ HttpGet httpGet;
+ try (InputStream inputStream = classLoader.getResourceAsStream("url.properties")) {
+ defaultProperties.load(inputStream);
+ String tempUrl = defaultProperties.getProperty("commitHistoryApiUrl");
+ String url = tempUrl.replaceFirst("REPO_LOCATION", repoLocation).replaceFirst("FILE_NAME", filePath);
+ httpGet = new HttpGet(url);
+ httpGet.addHeader(AUTHORIZATION, BEARER + githubAccessToken);
+ } catch (IllegalArgumentException e) {
+ throw new CodeQualityMetricsException("The url provided for accessing the Github Search Commit API is " +
+ "invalid ", e);
+ } catch (IOException e) {
+ throw new CodeQualityMetricsException("IO exception occurred when loading the inputstream to the " +
+ "properties object", e);
+ }
+ return ApiUtility.callApi(httpGet);
+ }
+
+ /**
+ * Used to call github single commit REST API.
+ *
+ * @param repoLocation repository location
+ * @param commitHash relevant commit hash to find details of
+ * @param githubAccessToken Github access token for accessing github API
+ * @return String representation of the json response
+ */
+ public static String callSingleCommitApi(String repoLocation, String commitHash, String githubAccessToken)
+ throws CodeQualityMetricsException {
+ HttpGet httpGet;
+ try (InputStream inputStream = classLoader.getResourceAsStream("url.properties")) {
+ defaultProperties.load(inputStream);
+ String tempUrl = defaultProperties.getProperty("singleCommitApiUrl");
+ String url = tempUrl.replaceFirst("REPO_LOCATION", repoLocation).replaceFirst("COMMIT_HASH", commitHash);
+ httpGet = new HttpGet(url);
+ httpGet.addHeader(AUTHORIZATION, BEARER + githubAccessToken);
+ } catch (IllegalArgumentException e) {
+ throw new CodeQualityMetricsException("The url provided for accessing the Github Search Commit API is " +
+ "invalid ", e);
+ } catch (IOException e) {
+ throw new CodeQualityMetricsException("IO exception occurred when loading the inputstream to the " +
+ "properties object", e);
+ }
+ return ApiUtility.callApi(httpGet);
+
+ }
+
+ /**
+ * Used to call the github review API.
+ *
+ * @param repoLocation repository name
+ * @param pullRequestNumber pull request number to be queried for
+ * @param githubAccessToken Github access token for accessing github API
+ * @return String representation of the json response
+ * @throws CodeQualityMetricsException results
+ */
+ public static String callReviewApi(String repoLocation, int pullRequestNumber, String githubAccessToken) throws
+ CodeQualityMetricsException {
+ HttpGet httpGet;
+ try (InputStream inputStream = classLoader.getResourceAsStream("url.properties")) {
+ defaultProperties.load(inputStream);
+ String tempUrl = defaultProperties.getProperty("reviewApiUrl");
+ String url = tempUrl.replaceFirst("REPO_LOCATION", repoLocation).replaceFirst("PULL_REQUEST_NUMBER",
+ String.valueOf(pullRequestNumber));
+ httpGet = new HttpGet(url);
+ httpGet.addHeader(ACCEPT, defaultProperties.getProperty("reviewApiUrlHeader"));
+ httpGet.addHeader(AUTHORIZATION, BEARER + githubAccessToken);
+ } catch (IllegalArgumentException e) {
+ throw new CodeQualityMetricsException("The url provided for accessing the Github Review Commit API is " +
+ "invalid ", e);
+ } catch (IOException e) {
+ throw new CodeQualityMetricsException("IO exception occurred when loading the inputstream to the " +
+ "properties object", e);
+ }
+ return ApiUtility.callApi(httpGet);
+ }
+
+ /**
+ * Used to call the github Issue Search API.
+ *
+ * @param commitHashToBeSearched commit hash to be searched for issues
+ * @param githubAccessToken Github access token for accessing github API
+ * @return String representation of the json response
+ * @throws CodeQualityMetricsException results
+ */
+ public static String callSearchIssueApi(String commitHashToBeSearched, String githubAccessToken) throws
+ CodeQualityMetricsException {
+ HttpGet httpGet;
+ try (InputStream inputStream = classLoader.getResourceAsStream("url.properties")) {
+ defaultProperties.load(inputStream);
+ String url = defaultProperties.getProperty("searchIssueApiUrl") + commitHashToBeSearched;
+ httpGet = new HttpGet(url);
+ httpGet.addHeader(ACCEPT, defaultProperties.getProperty("searchIssueApiUrlHeader"));
+ httpGet.addHeader(AUTHORIZATION, BEARER + githubAccessToken);
+ } catch (IllegalArgumentException e) {
+ throw new CodeQualityMetricsException("The url provided for accessing the Github Search Issue API is " +
+ "invalid ", e);
+ } catch (IOException e) {
+ throw new CodeQualityMetricsException("IO exception occurred when loading the inputstream to the " +
+ "properties object", e);
+ }
+ return ApiUtility.callApi(httpGet);
+ }
+
+ /**
+ * Used for calling the github graphql API.
+ *
+ * @param graphqlJsonStructure JSON input structure for calling the graphql API
+ * @param githubToken Github access token for accessing github API
+ * @return String representation of the json response
+ * @throws CodeQualityMetricsException results
+ */
+ public static String callGraphqlApi(JSONObject graphqlJsonStructure, String githubToken) throws
+ CodeQualityMetricsException {
+ HttpPost httpPost;
+ try (InputStream inputStream = classLoader.getResourceAsStream("url.properties")) {
+ defaultProperties.load(inputStream);
+ String url = defaultProperties.getProperty("githubGraphqlUrl");
+ httpPost = new HttpPost(url);
+ httpPost.addHeader(AUTHORIZATION, BEARER + githubToken);
+ httpPost.addHeader(ACCEPT, defaultProperties.getProperty("githubGraphqlUrlHeader"));
+ StringEntity entity = new StringEntity(graphqlJsonStructure.toString());
+ httpPost.setEntity(entity);
+ } catch (IllegalArgumentException e) {
+ throw new CodeQualityMetricsException("The url provided for accessing the Github Graphql API is " +
+ "invalid", e);
+ } catch (UnsupportedEncodingException e) {
+ throw new CodeQualityMetricsException("An error occurred when creating the String entity from Json " +
+ "Structure", e);
+ } catch (IOException e) {
+ throw new CodeQualityMetricsException("IO exception occurred when loading the inputstream to the " +
+ "properties object", e);
+ }
+ return ApiUtility.callGraphQlApi(httpPost);
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/PmtApiCaller.java b/src/main/java/com/wso2/code/quality/metrics/PmtApiCaller.java
new file mode 100644
index 0000000..c49d8fd
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/PmtApiCaller.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+import com.wso2.code.quality.metrics.exceptions.CodeQualityMetricsException;
+import org.apache.http.client.methods.HttpGet;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import static com.wso2.code.quality.metrics.model.Constants.AUTHORIZATION;
+import static com.wso2.code.quality.metrics.model.Constants.BEARER;
+
+/**
+ * Used for all the WSO2 PMT communications.
+ *
+ * @since 1.0.0
+ */
+public class PmtApiCaller {
+
+ /**
+ * Used for calling the WSO2 PMT REST API.
+ *
+ * @param accessToken WSO2 PMT access token
+ * @param patchId Patch Id
+ * @return String representation of the json response
+ * @throws CodeQualityMetricsException results
+ */
+ public String callApi(String accessToken, String patchId) throws CodeQualityMetricsException {
+ HttpGet httpGet;
+ Properties defaultProperties = new Properties();
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ try (InputStream inputStream = classLoader.getResourceAsStream("url.properties")) {
+ defaultProperties.load(inputStream);
+ String pmtApiUrl = defaultProperties.getProperty("pmtApiUrl");
+ String pmtUrl = pmtApiUrl + patchId;
+ httpGet = new HttpGet(pmtUrl);
+ httpGet.addHeader(AUTHORIZATION, BEARER + accessToken);
+ } catch (IllegalArgumentException e) {
+ throw new CodeQualityMetricsException("The url provided for accessing the PMT API is invalid ", e);
+ } catch (IOException e) {
+ throw new CodeQualityMetricsException("IO exception occurred when loading the inputstream to the " +
+ "properties object", e);
+ }
+ return ApiUtility.callApi(httpGet);
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/ReviewAnalyser.java b/src/main/java/com/wso2/code/quality/metrics/ReviewAnalyser.java
new file mode 100644
index 0000000..b4ba0ab
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/ReviewAnalyser.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
+import com.google.gson.reflect.TypeToken;
+import com.wso2.code.quality.metrics.exceptions.CodeQualityMetricsException;
+import com.wso2.code.quality.metrics.model.IssueApiResponse;
+import com.wso2.code.quality.metrics.model.ReviewApiResponse;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static com.wso2.code.quality.metrics.model.Constants.GITHUB_REVIEW_API_CLOSED_STATE;
+import static com.wso2.code.quality.metrics.model.Constants.GITHUB_REVIEW_APPROVED;
+import static com.wso2.code.quality.metrics.model.Constants.GITHUB_REVIEW_COMMENTED;
+
+/**
+ * Used to find the reviewers of the buggy lines of code.
+ *
+ * @since 1.0.0
+ */
+
+public class ReviewAnalyser {
+ private static final Logger logger = Logger.getLogger(ReviewAnalyser.class);
+
+ // to store the reviewed and approved users of the pull requests
+ private final Set approvedReviewers = new HashSet<>();
+ private final Set commentedReviewers = new HashSet<>();
+ private final Gson gson = new Gson();
+
+ /**
+ * Used to prevent SIC_INNER_SHOULD_BE_STATIC_ANON error that comes when building with WSO2 parent
+ * pom. As suggested by the above error an static inner class is used to prevent the error.
+ */
+ private static class ListType extends TypeToken> {
+ }
+
+ /**
+ * Used to identify the pull requests that introduce the given commit to the code base.
+ *
+ * @param authorCommits Commits which the relevant pull request no must be found
+ * @param githubToken Github access token for accessing github API
+ */
+ void findReviewers(Set authorCommits, String githubToken) {
+ authorCommits.forEach(commitHash -> {
+ String jsonText;
+ try {
+ jsonText = GithubApiCallerUtils.callSearchIssueApi(commitHash, githubToken);
+ Map> prNoWithRepoName = savePrNumberAndRepoName(jsonText);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Relevant pull requests on patch " + commitHash + " with their relevant repository " +
+ "names are successfully saved in a map.");
+ }
+ saveReviewers(prNoWithRepoName, githubToken);
+ } catch (CodeQualityMetricsException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ });
+ }
+
+ /**
+ * Used to save the pull requests with their relevant repository names in a map.
+ *
+ * @param jsonText json reponse received from the github issue API
+ * @return a map of pull requests againt their repository name
+ * @throws CodeQualityMetricsException results
+ */
+ private Map> savePrNumberAndRepoName(String jsonText) throws CodeQualityMetricsException {
+ // map for storing the pull requests numbers against their Repository
+ Map> prNoWithRepoName = new HashMap<>();
+ try {
+ IssueApiResponse issueApiResponse = gson.fromJson(jsonText, IssueApiResponse.class);
+ issueApiResponse.getIssue().parallelStream()
+ .filter(searchItem -> GITHUB_REVIEW_API_CLOSED_STATE.equals(searchItem.getPrState()))
+ .filter(searchItem -> StringUtils.contains(searchItem.getRepositoryUrl(), "/wso2/"))
+ .forEach(searchItem -> {
+ String repositoryName = StringUtils.substringAfter(searchItem.getRepositoryUrl(),
+ "repos/");
+ int pullRequestNo = searchItem.getPrNumber();
+ prNoWithRepoName.putIfAbsent(repositoryName, new HashSet<>());
+ if (!prNoWithRepoName.get(repositoryName).contains(pullRequestNo)) {
+ prNoWithRepoName.get(repositoryName).add(pullRequestNo);
+ }
+ });
+ } catch (JsonSyntaxException e) {
+ throw new CodeQualityMetricsException(e.getMessage(), e.getCause());
+ }
+ return prNoWithRepoName;
+ }
+
+ /**
+ * Used to save the names of the users who has approved and commented on the pull requests which
+ * introduce bug lines of code to the code base. Approved users are saved in approvedReviewers list while
+ * commented users are saved in commentedReviewers list.
+ *
+ * @param prNoWithRepoName Map containg the pull requests which introduce bug lines to the code base against the
+ * relevant reposiory
+ * @param githubToken Github access token for accessing github API
+ */
+ private void saveReviewers(Map> prNoWithRepoName, String githubToken) {
+ prNoWithRepoName.forEach((repositoryName, prNumbers) -> prNumbers.parallelStream()
+ .forEach((Integer prNumber) -> {
+ try {
+ String jsonText = GithubApiCallerUtils.callReviewApi(repositoryName, prNumber, githubToken);
+ if (jsonText != null && !jsonText.isEmpty()) {
+ Type listType = new ListType().getType();
+ List reviews = gson.fromJson(jsonText, listType);
+ // to filter Approved users
+ reviews.parallelStream()
+ .filter(review -> GITHUB_REVIEW_APPROVED.equals(review.getReviewState()))
+ .forEach(review -> approvedReviewers.add(review.getReviewer().getName()));
+ logger.debug("Users who approved the pull requests which introduce bug lines to the " +
+ "code base are successfully saved to approvedReviewers list");
+ reviews.parallelStream()
+ .filter(review -> GITHUB_REVIEW_COMMENTED.equals(review.getReviewState()))
+ .forEach(review -> commentedReviewers.add(review.getReviewer().getName()));
+ logger.debug("Users who commented on the pull requests which introduce bug lines to " +
+ "the code base are successfully saved to approvedReviewers list");
+ } else {
+ logger.warn("There are no records of reviews for pull request: " + prNumber +
+ " on " + repositoryName + " repository");
+ }
+ } catch (CodeQualityMetricsException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ }));
+ }
+
+ /**
+ * Print the list of reviewers and commented users on the pull requests which introduce bugs to the code base.
+ */
+ void printReviewUsers() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("\n Reviewed and approved users of the bug lines: " + approvedReviewers);
+ logger.debug("\n Reviewed and commented users on bug lines: " + commentedReviewers);
+ }
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/SdkGitHubClient.java b/src/main/java/com/wso2/code/quality/metrics/SdkGitHubClient.java
new file mode 100644
index 0000000..e400a82
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/SdkGitHubClient.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+import com.wso2.code.quality.metrics.exceptions.CodeQualityMetricsException;
+import org.apache.log4j.Logger;
+import org.eclipse.egit.github.core.CommitFile;
+import org.eclipse.egit.github.core.IRepositoryIdProvider;
+import org.eclipse.egit.github.core.RepositoryCommit;
+import org.eclipse.egit.github.core.client.GitHubClient;
+import org.eclipse.egit.github.core.service.CommitService;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Used for communicating with the github REST API from egit github API.
+ *
+ * @since 1.0.0
+ */
+
+public class SdkGitHubClient {
+ private static final Logger logger = Logger.getLogger(SdkGitHubClient.class);
+
+ private CommitService commitService = null;
+
+ SdkGitHubClient(String githubToken) {
+ GitHubClient gitHubClient = new GitHubClient();
+ gitHubClient.setOAuth2Token(githubToken);
+ commitService = new CommitService(gitHubClient);
+ }
+
+ /**
+ * Used for saving the files changed and their relevant changed line ranges from
+ * the given commit in the given Repository.
+ *
+ * @param repositoryName The Repository name that contain the given commit hash
+ * @param commitHash The querying commit hash
+ * @return a map containg arraylist of file changed and their relevant patch
+ */
+ Map getFilesChanged(String repositoryName, String commitHash)
+ throws CodeQualityMetricsException {
+ Map fileNamesAndPatches = new HashMap<>();
+ try {
+ IRepositoryIdProvider iRepositoryIdProvider = () -> repositoryName;
+ RepositoryCommit repositoryCommit = commitService.getCommit(iRepositoryIdProvider, commitHash);
+ List filesChanged = repositoryCommit.getFiles();
+ // this can be run parallely as patchString of a file will always be with the same file
+ filesChanged.parallelStream()
+ .forEach(commitFile -> fileNamesAndPatches.put(commitFile.getFilename(), commitFile.getPatch()));
+ if (logger.isDebugEnabled()) {
+ logger.debug("for commit hash " + commitHash + " on the " + repositoryName + " repository, files" +
+ " changed and their relevant patch strings are saved to the map successfully");
+ }
+ } catch (IOException e) {
+ throw new CodeQualityMetricsException("IO Exception occurred when searching for files changed on the " +
+ "commit " + commitHash + " on " + repositoryName + " Repository", e);
+ }
+ return fileNamesAndPatches;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/exceptions/CodeQualityMetricsException.java b/src/main/java/com/wso2/code/quality/metrics/exceptions/CodeQualityMetricsException.java
new file mode 100644
index 0000000..711df8e
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/exceptions/CodeQualityMetricsException.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.exceptions;
+
+/**
+ * The exception class for all Code Quality Matrices project related exceptions.
+ *
+ * @since 1.0.0
+ */
+public class CodeQualityMetricsException extends Exception {
+ public CodeQualityMetricsException(String message) {
+ super(message);
+ }
+
+ public CodeQualityMetricsException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/Author.java b/src/main/java/com/wso2/code/quality/metrics/model/Author.java
new file mode 100644
index 0000000..7fe4cd5
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/Author.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github REST API.
+ *
+ * @since 1.0.0
+ */
+public class Author {
+
+ @SerializedName("date")
+ private String date;
+
+ public String getDate() {
+ return date;
+ }
+
+ public void setDate(String date) {
+ this.date = date;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/Commit.java b/src/main/java/com/wso2/code/quality/metrics/model/Commit.java
new file mode 100644
index 0000000..b73150f
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/Commit.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github REST API.
+ *
+ * @since 1.0.0
+ */
+public class Commit {
+ @SerializedName("author")
+ private Author author;
+
+ public Author getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(Author author) {
+ this.author = author;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/CommitHistoryApiResponse.java b/src/main/java/com/wso2/code/quality/metrics/model/CommitHistoryApiResponse.java
new file mode 100644
index 0000000..fde0f59
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/CommitHistoryApiResponse.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github REST API.
+ *
+ * @since 1.0.0
+ */
+public class CommitHistoryApiResponse {
+ @SerializedName("sha")
+ private String commitHash;
+
+ @SerializedName("commit")
+ private Commit commit;
+
+ public String getCommitHash() {
+ return commitHash;
+ }
+
+ public void setCommitHash(String commitHash) {
+ this.commitHash = commitHash;
+ }
+
+ public Commit getCommit() {
+ return commit;
+ }
+
+ public void setCommit(Commit commit) {
+ this.commit = commit;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/Constants.java b/src/main/java/com/wso2/code/quality/metrics/model/Constants.java
new file mode 100644
index 0000000..5d5096c
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/Constants.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+/**
+ * Used for storing all the constants used in the Code quality metrics Application.
+ *
+ * @since 1.0.0
+ */
+public class Constants {
+ public static final String COMMITS_INSIDE_GIVEN_PATCH = "patchInformation_svnRevisionpublic";
+ public static final String GITHUB_REVIEW_APPROVED = "APPROVED";
+ public static final String GITHUB_REVIEW_COMMENTED = "COMMENTED";
+ public static final String GITHUB_REVIEW_API_CLOSED_STATE = "closed";
+ public static final String AUTHORIZATION = "Authorization";
+ public static final String BEARER = "Bearer ";
+ public static final String ACCEPT = "Accept";
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/GraphQlResponse.java b/src/main/java/com/wso2/code/quality/metrics/model/GraphQlResponse.java
new file mode 100644
index 0000000..2c2f08f
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/GraphQlResponse.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github graphql API.
+ *
+ * @since 1.0.0
+ */
+public class GraphQlResponse {
+ @SerializedName("data")
+ private GraphqlData response;
+
+ public GraphqlData getResponse() {
+ return response;
+ }
+
+ public void setResponse(GraphqlData response) {
+ this.response = response;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/Graphql.java b/src/main/java/com/wso2/code/quality/metrics/model/Graphql.java
new file mode 100644
index 0000000..db8fcfb
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/Graphql.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import java.io.Serializable;
+
+/**
+ * This is a bean class used to set the json input structures for calling the github graphql API.
+ *
+ * @since 1.0.0
+ */
+public class Graphql implements Serializable {
+ private String graphqlInputWithoutHistory;
+ private static final long serialVersionUID = 42L;
+
+ public Graphql() {
+ }
+
+ public String getGraphqlInputWithoutHistory() {
+ return graphqlInputWithoutHistory;
+ }
+
+ public void setGraphqlInputWithoutHistory(String owner, String repositoryName, String
+ parentCommitHashForCallingGraphQl, String fileName) {
+ this.graphqlInputWithoutHistory = "{repository(owner:\"" + owner + "\",name:\"" + repositoryName + "\")" +
+ "{object(expression:\"" + parentCommitHashForCallingGraphQl + "\"){ ... on Commit{blame(path:\"" +
+ fileName + "\"){ranges{startingLine endingLine age commit{ url author { name email } } } } } } } }";
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/GraphqlAuthor.java b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlAuthor.java
new file mode 100644
index 0000000..dd4605d
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlAuthor.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github graphql API.
+ *
+ * @since 1.0.0
+ */
+public class GraphqlAuthor {
+ @SerializedName("name")
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/GraphqlBlame.java b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlBlame.java
new file mode 100644
index 0000000..55bf9d3
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlBlame.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.util.List;
+
+/**
+ * Pojo class used for parsing JSON response received from github graphql API.
+ *
+ * @since 1.0.0
+ */
+public class GraphqlBlame {
+ @SerializedName("ranges")
+ private List ranges;
+
+ public List getRanges() {
+ return ranges;
+ }
+
+ public void setRanges(List ranges) {
+ this.ranges = ranges;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/GraphqlCommit.java b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlCommit.java
new file mode 100644
index 0000000..89e2342
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlCommit.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github graphql API.
+ *
+ * @since 1.0.0
+ */
+public class GraphqlCommit {
+ @SerializedName("author")
+ private GraphqlAuthor author;
+
+ @SerializedName("url")
+ private String url;
+
+ public GraphqlAuthor getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(GraphqlAuthor author) {
+ this.author = author;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/GraphqlData.java b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlData.java
new file mode 100644
index 0000000..cf4a8d1
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlData.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github graphql API.
+ *
+ * @since 1.0.0
+ */
+public class GraphqlData {
+ @SerializedName("repository")
+ private GraphqlRepository repository;
+
+ public GraphqlRepository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(GraphqlRepository repository) {
+ this.repository = repository;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/GraphqlObject.java b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlObject.java
new file mode 100644
index 0000000..edc9bea
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlObject.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github graphql API.
+ *
+ * @since 1.0.0
+ */
+public class GraphqlObject {
+ @SerializedName("blame")
+ private GraphqlBlame blame;
+
+ public GraphqlBlame getBlame() {
+ return blame;
+ }
+
+ public void setBlame(GraphqlBlame blame) {
+ this.blame = blame;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/GraphqlRange.java b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlRange.java
new file mode 100644
index 0000000..1c0cad9
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlRange.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github graphql API.
+ *
+ * @since 1.0.0
+ */
+public class GraphqlRange {
+ @SerializedName("startingLine")
+ private int startingLine;
+
+ @SerializedName("endingLine")
+ private int endingLine;
+
+ @SerializedName("age")
+ private int age;
+
+ @SerializedName("commit")
+ private GraphqlCommit commit;
+
+ public int getStartingLine() {
+ return startingLine;
+ }
+
+ public void setStartingLine(int startingLine) {
+ this.startingLine = startingLine;
+ }
+
+ public int getEndingLine() {
+ return endingLine;
+ }
+
+ public void setEndingLine(int endingLine) {
+ this.endingLine = endingLine;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public GraphqlCommit getCommit() {
+ return commit;
+ }
+
+ public void setCommit(GraphqlCommit commit) {
+ this.commit = commit;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/GraphqlRepository.java b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlRepository.java
new file mode 100644
index 0000000..f57e421
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/GraphqlRepository.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github graphql API.
+ *
+ * @since 1.0.0
+ */
+public class GraphqlRepository {
+ @SerializedName("object")
+ private GraphqlObject file;
+
+ public GraphqlObject getFile() {
+ return file;
+ }
+
+ public void setFile(GraphqlObject file) {
+ this.file = file;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/IssueApiResponse.java b/src/main/java/com/wso2/code/quality/metrics/model/IssueApiResponse.java
new file mode 100644
index 0000000..57f1964
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/IssueApiResponse.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.util.List;
+
+/**
+ * Pojo class used for parsing JSON response received from github REST API.
+ *
+ * @since 1.0.0
+ */
+public class IssueApiResponse {
+ @SerializedName("items")
+ private List issue;
+
+ public List getIssue() {
+ return issue;
+ }
+
+ public void setIssue(List issue) {
+ this.issue = issue;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/ParentCommit.java b/src/main/java/com/wso2/code/quality/metrics/model/ParentCommit.java
new file mode 100644
index 0000000..73a3557
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/ParentCommit.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github single commit REST API.
+ *
+ * @since 1.0.0
+ */
+public class ParentCommit {
+ @SerializedName("sha")
+ private String commitHash;
+
+ public String getCommitHash() {
+ return commitHash;
+ }
+
+ public void setCommitHash(String commitHash) {
+ this.commitHash = commitHash;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/Repository.java b/src/main/java/com/wso2/code/quality/metrics/model/Repository.java
new file mode 100644
index 0000000..3e9be7f
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/Repository.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github REST API.
+ *
+ * @since 1.0.0
+ */
+public class Repository {
+ @SerializedName("full_name")
+ private String repositoryLocation;
+
+ public String getRepositoryLocation() {
+ return repositoryLocation;
+ }
+
+ public void setRepositoryLocation(String repositoryLocation) {
+ this.repositoryLocation = repositoryLocation;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/RepositoryItem.java b/src/main/java/com/wso2/code/quality/metrics/model/RepositoryItem.java
new file mode 100644
index 0000000..9bbc8b1
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/RepositoryItem.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github graphql API.
+ *
+ * @since 1.0.0
+ */
+public class RepositoryItem {
+ @SerializedName("repository")
+ private Repository repository;
+
+ public Repository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(Repository repository) {
+ this.repository = repository;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/ReviewApiResponse.java b/src/main/java/com/wso2/code/quality/metrics/model/ReviewApiResponse.java
new file mode 100644
index 0000000..03f324a
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/ReviewApiResponse.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github REST API.
+ *
+ * @since 1.0.0
+ */
+public class ReviewApiResponse {
+ @SerializedName("state")
+ private String reviewState;
+
+ @SerializedName("user")
+ private Reviewer reviewer;
+
+ public String getReviewState() {
+ return reviewState;
+ }
+
+ public void setReviewState(String reviewState) {
+ this.reviewState = reviewState;
+ }
+
+ public Reviewer getReviewer() {
+ return reviewer;
+ }
+
+ public void setReviewer(Reviewer reviewer) {
+ this.reviewer = reviewer;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/Reviewer.java b/src/main/java/com/wso2/code/quality/metrics/model/Reviewer.java
new file mode 100644
index 0000000..905ebab
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/Reviewer.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github REST API.
+ *
+ * @since 1.0.0
+ */
+public class Reviewer {
+ @SerializedName("login")
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setReviewer(String login) {
+ this.name = login;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/SearchApiResponse.java b/src/main/java/com/wso2/code/quality/metrics/model/SearchApiResponse.java
new file mode 100644
index 0000000..616cf49
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/SearchApiResponse.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.util.List;
+
+/**
+ * Pojo class used for parsing JSON response received from github REST API.
+ *
+ * @since 1.0.0
+ */
+public class SearchApiResponse {
+ @SerializedName("items")
+ private List containingRepositories;
+
+ public List getContainingRepositories() {
+ return containingRepositories;
+ }
+
+ public void setContainingRepositories(List containingRepositories) {
+ this.containingRepositories = containingRepositories;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/SearchItem.java b/src/main/java/com/wso2/code/quality/metrics/model/SearchItem.java
new file mode 100644
index 0000000..dbf92eb
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/SearchItem.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Pojo class used for parsing JSON response received from github REST API.
+ *
+ * @since 1.0.0
+ */
+public class SearchItem {
+ @SerializedName("state")
+ private String prState;
+
+ @SerializedName("number")
+ private int prNumber;
+
+ @SerializedName("repository_url")
+ private String repositoryUrl;
+
+ public String getPrState() {
+ return prState;
+ }
+
+ public void setPrState(String prState) {
+ this.prState = prState;
+ }
+
+ public int getPrNumber() {
+ return prNumber;
+ }
+
+ public void setPrNumber(int prNumber) {
+ this.prNumber = prNumber;
+ }
+
+ public String getRepositoryUrl() {
+ return repositoryUrl;
+ }
+
+ public void setRepositoryUrl(String repositoryUrl) {
+ this.repositoryUrl = repositoryUrl;
+ }
+}
diff --git a/src/main/java/com/wso2/code/quality/metrics/model/SingleCommitApiResponse.java b/src/main/java/com/wso2/code/quality/metrics/model/SingleCommitApiResponse.java
new file mode 100644
index 0000000..63782c0
--- /dev/null
+++ b/src/main/java/com/wso2/code/quality/metrics/model/SingleCommitApiResponse.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics.model;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.util.List;
+
+/**
+ * Pojo class used for parsing JSON response received from github single commit REST API.
+ *
+ * @since 1.0.0
+ */
+public class SingleCommitApiResponse {
+ @SerializedName("parents")
+ private List parentCommits;
+
+ public List getParentCommits() {
+ return parentCommits;
+ }
+
+ public void setParentCommits(List parentCommits) {
+ this.parentCommits = parentCommits;
+ }
+}
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
new file mode 100644
index 0000000..c06a553
--- /dev/null
+++ b/src/main/resources/log4j.properties
@@ -0,0 +1,34 @@
+#
+# Copyright (c) 2017 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+# WSO2 Inc. licenses this file to you under the Apache License,
+# Version 2.0 (the "License"); you may not use this file except
+# in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+# Define the root logger with appender file
+log4j.rootLogger=DEBUG, APPENDER1,CONSOLE
+#Limiting logging level of log4j to WARN level
+log4j.logger.org.apache.http=WARN
+#Define the file appender
+log4j.appender.APPENDER1=org.apache.log4j.RollingFileAppender
+log4j.appender.APPENDER1.File=${user.home}/log.out
+log4j.appender.APPENDER1.MaxFileSize=10KB
+log4j.appender.APPENDER1.MaxBackupIndex=5
+# Define the layout for file appender
+log4j.appender.APPENDER1.layout=org.apache.log4j.PatternLayout
+log4j.appender.APPENDER1.layout.conversionPattern=%d{yyyy-MM-dd}-5p--10c:%m%n
+
+log4j.appender.CONSOLE= org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Target=System.out
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.conversionPattern=%d{yyyy-MM-dd}-5p--10c:%m%n
diff --git a/src/main/resources/tokens.properties b/src/main/resources/tokens.properties
new file mode 100644
index 0000000..706b1fd
--- /dev/null
+++ b/src/main/resources/tokens.properties
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+#
+# WSO2 Inc. licenses this file to you under the Apache License,
+# Version 2.0 (the "License"); you may not use this file except
+# in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+pmtToken=dFFVNXZ4enJHZUJwTE1RdXdPc0pXX2Z5WUxZYQ==
+githubToken=ZjQxZTcwOTJmY2I1NTZmZTI2YzFlMDgwYjFjNDQ3NWRhYTZmN2MyNw
diff --git a/src/main/resources/url.properties b/src/main/resources/url.properties
new file mode 100644
index 0000000..e622b92
--- /dev/null
+++ b/src/main/resources/url.properties
@@ -0,0 +1,28 @@
+#
+# Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+#
+# WSO2 Inc. licenses this file to you under the Apache License,
+# Version 2.0 (the "License"); you may not use this file except
+# in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+pmtApiUrl=http://umt.private.wso2.com:9765/codequalitymatricesapi/1.0.0/properties?path=/_system/governance/patchs/
+searchCommitApiUrl=https://api.github.com/search/commits?q=hash%3A
+searchCommitApiHeader=application/vnd.github.cloak-preview
+searchIssueApiUrl=https://api.github.com/search/issues?q=
+searchIssueApiUrlHeader=application/vnd.github.mercy-preview+json
+commitHistoryApiUrl=https://api.github.com/repos/REPO_LOCATION/commits?path=FILE_NAME
+githubGraphqlUrl=https://api.github.com/graphql
+githubGraphqlUrlHeader=application/json
+reviewApiUrl=https://api.github.com/repos/REPO_LOCATION/pulls/PULL_REQUEST_NUMBER/reviews
+reviewApiUrlHeader=application/vnd.github.black-cat-preview+json
+singleCommitApiUrl=https://api.github.com/repos/REPO_LOCATION/commits/COMMIT_HASH
diff --git a/src/test/java/com/wso2/code/quality/metrics/ChangesFinderTest.java b/src/test/java/com/wso2/code/quality/metrics/ChangesFinderTest.java
new file mode 100644
index 0000000..25ba98d
--- /dev/null
+++ b/src/test/java/com/wso2/code/quality/metrics/ChangesFinderTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.Logger;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * A class used to test identifyChangedFile method of the ChangeFinder class
+ *
+ * @since 1.0.0
+ */
+public class ChangesFinderTest {
+ private static final Logger logger = Logger.getLogger(ChangesFinderTest.class);
+
+ @Test
+ public void testIdentifyDeletedLines() {
+ String patchString;
+ Set actualDeltedLinesForPatchString;
+ Set expectedDeltedLinesForPatchString1 = new HashSet<>();
+ expectedDeltedLinesForPatchString1.add(822);
+ expectedDeltedLinesForPatchString1.add(823);
+ expectedDeltedLinesForPatchString1.add(824);
+ expectedDeltedLinesForPatchString1.add(907);
+ expectedDeltedLinesForPatchString1.add(908);
+ expectedDeltedLinesForPatchString1.add(909);
+ expectedDeltedLinesForPatchString1.add(1081);
+ expectedDeltedLinesForPatchString1.add(1082);
+ expectedDeltedLinesForPatchString1.add(1083);
+ expectedDeltedLinesForPatchString1.add(1087);
+ expectedDeltedLinesForPatchString1.add(1094);
+ expectedDeltedLinesForPatchString1.add(1143);
+ expectedDeltedLinesForPatchString1.add(1144);
+ expectedDeltedLinesForPatchString1.add(1145);
+ expectedDeltedLinesForPatchString1.add(1146);
+ expectedDeltedLinesForPatchString1.add(1147);
+ expectedDeltedLinesForPatchString1.add(1148);
+ expectedDeltedLinesForPatchString1.add(1149);
+ expectedDeltedLinesForPatchString1.add(1150);
+ expectedDeltedLinesForPatchString1.add(1151);
+ expectedDeltedLinesForPatchString1.add(1152);
+ expectedDeltedLinesForPatchString1.add(1153);
+ expectedDeltedLinesForPatchString1.add(1165);
+ try {
+ Class> changeFinderClass = Class.forName("com.wso2.code.quality.metrics.ChangesFinder");
+ Object changeFinder = changeFinderClass.newInstance();
+ Method identifyDeletedLinesMethod = changeFinderClass.getDeclaredMethod("identifyDeletedLines",
+ String.class);
+ patchString = readFile("patchStrings/patchString1.txt");
+ actualDeltedLinesForPatchString = (Set) identifyDeletedLinesMethod.invoke(changeFinder,
+ patchString);
+ assertThat(actualDeltedLinesForPatchString.size(), is(expectedDeltedLinesForPatchString1.size()));
+ assertThat(actualDeltedLinesForPatchString, is(expectedDeltedLinesForPatchString1));
+ patchString = readFile("patchStrings/patchString2.txt");
+ actualDeltedLinesForPatchString = (Set) identifyDeletedLinesMethod.invoke(changeFinder,
+ patchString);
+ assertTrue(actualDeltedLinesForPatchString.isEmpty());
+ } catch (IllegalAccessException | ClassNotFoundException | InstantiationException | NoSuchMethodException
+ | InvocationTargetException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ }
+
+ /**
+ * This is used to get the contents of the txt file as a single String
+ *
+ * @param path location path to the relevant txt file
+ * @return single String containing all the contents of the given file
+ */
+ private String readFile(String path) {
+ String result = "";
+ ClassLoader classLoader = getClass().getClassLoader();
+ try {
+ result = IOUtils.toString(classLoader.getResourceAsStream(path));
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ return result;
+ }
+}
diff --git a/src/test/java/com/wso2/code/quality/metrics/CodeQualityMetricsExecutorTest.java b/src/test/java/com/wso2/code/quality/metrics/CodeQualityMetricsExecutorTest.java
new file mode 100644
index 0000000..a5fbfd3
--- /dev/null
+++ b/src/test/java/com/wso2/code/quality/metrics/CodeQualityMetricsExecutorTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+
+import com.wso2.code.quality.metrics.exceptions.CodeQualityMetricsException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * A class used to test findCommitHashesInPatch method of the CodeQualityMetricsExecutor class
+ *
+ * @since 1.0.0
+ */
+public class CodeQualityMetricsExecutorTest {
+
+ @Rule
+ public final ExpectedException exception = ExpectedException.none();
+
+ @Test
+ public void testFindCommitHashesInPatch() throws CodeQualityMetricsException {
+ String pmtToken = new Token().getPmtToken();
+ String githubToken = new Token().getGithubToken();
+ Map> patchesAndCommits = new HashMap<>();
+ patchesAndCommits.put("WSO2-CARBON-PATCH-4.4.0-0680", Arrays.asList("eaa45529cbabc5f30a2ffaa4781821ad0a5223ab"
+ , "2b1d973d089ebc3af3b9e7b893f48cf905758cf4"));
+ patchesAndCommits.put("WSO2-CARBON-PATCH-4.4.0-0682",
+ Collections.singletonList("e3c3457149b109178d510aac965d5a85cc465aa0"));
+ patchesAndCommits.put("WSO2-CARBON-PATCH-4.4.0-0692",
+ Collections.singletonList("67a60e081c8e0fe01d087f60cd9b629bcea172ae"));
+ for (Map.Entry> map : patchesAndCommits.entrySet()) {
+ CodeQualityMetricsExecutor codeQualityMetricsExecutor = new CodeQualityMetricsExecutor(pmtToken,
+ map.getKey(), githubToken);
+ List commitHashes = codeQualityMetricsExecutor.findCommitHashesInPatch();
+ assertEquals("Must match with the relevant commit list", map.getValue(), commitHashes);
+ }
+ }
+
+ @Test
+ public void testFindCommitHashesInPatchForException() throws CodeQualityMetricsException {
+ CodeQualityMetricsExecutor codeQualityMetricsExecutor = new CodeQualityMetricsExecutor("pmtToken",
+ "patch1", "githubToken");
+ exception.expect(CodeQualityMetricsException.class);
+ exception.expectMessage("Error occurred while calling PMT API");
+ codeQualityMetricsExecutor.findCommitHashesInPatch();
+ }
+}
diff --git a/src/test/java/com/wso2/code/quality/metrics/GithubResponsesTest.java b/src/test/java/com/wso2/code/quality/metrics/GithubResponsesTest.java
new file mode 100644
index 0000000..966d850
--- /dev/null
+++ b/src/test/java/com/wso2/code/quality/metrics/GithubResponsesTest.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+import com.wso2.code.quality.metrics.exceptions.CodeQualityMetricsException;
+import org.apache.log4j.Logger;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * A class used to test saveRepoNames,savePrNumberAndRepoName and saveReviewers methods of the GithubResponses class
+ *
+ * @since 1.0.0
+ */
+public class GithubResponsesTest {
+ private static final Logger logger = Logger.getLogger(GithubResponsesTest.class);
+ private static String githubToken;
+ private static Class> changesFinderClass;
+ private static Class> reviewAnalyserClass;
+
+ @BeforeClass
+ public static void setupTheEnvironment() throws CodeQualityMetricsException {
+ githubToken = new Token().getGithubToken();
+ try {
+ changesFinderClass = Class.forName("com.wso2.code.quality.metrics.ChangesFinder");
+ reviewAnalyserClass = Class.forName("com.wso2.code.quality.metrics.ReviewAnalyser");
+ } catch (ClassNotFoundException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ }
+
+ @Test
+ public void testObtainRepoNamesForCommitHashes() throws CodeQualityMetricsException {
+ List commitHash = new ArrayList<>();
+ commitHash.add("ad0debb15f1abac020b8ba69066ae4ebec782bdc");
+ Set expectedAuthorCommits = new HashSet<>();
+ expectedAuthorCommits.add("90fec04e4ac05281612de8d445c5767c26433b0d");
+ try {
+ Method obtainRepoNamesForCommitHashesMethod = changesFinderClass.getDeclaredMethod
+ ("obtainRepoNamesForCommitHashes", String.class, List.class);
+ obtainRepoNamesForCommitHashesMethod.setAccessible(true);
+ Object changesFinder = changesFinderClass.newInstance();
+ @SuppressWarnings("unchecked")
+ Set actualAuthorCommits = (Set) obtainRepoNamesForCommitHashesMethod.invoke
+ (changesFinder, githubToken, commitHash);
+ assertThat(actualAuthorCommits.size(), is(expectedAuthorCommits.size()));
+ assertThat(actualAuthorCommits, is(expectedAuthorCommits));
+ } catch (NoSuchMethodException | InstantiationException | IllegalAccessException |
+ InvocationTargetException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ }
+
+ @Test
+ public void testSaveRepoNames() {
+ Map> commitHashWithRepoNames = new HashMap<>();
+ commitHashWithRepoNames.put("eaa45529cbabc5f30a2ffaa4781821ad0a5223ab",
+ Collections.singletonList("wso2/carbon-apimgt"));
+ commitHashWithRepoNames.put("2b1d973d089ebc3af3b9e7b893f48cf905758cf4",
+ Collections.singletonList("wso2/carbon-apimgt"));
+ commitHashWithRepoNames.put("e3c3457149b109178d510aac965d5a85cc465aa0",
+ Collections.singletonList("wso2/wso2-axis2-transports"));
+ commitHashWithRepoNames.forEach((commitHash, repository) -> {
+ try {
+ String jsonText = GithubApiCallerUtils.callSearchCommitApi(commitHash, githubToken);
+ Method saveRepoNamesMethod = changesFinderClass.getDeclaredMethod("saveRepoNames", String.class);
+ saveRepoNamesMethod.setAccessible(true);
+ Object changesFinder = changesFinderClass.newInstance();
+ @SuppressWarnings("unchecked")
+ List repoLocations = (List) saveRepoNamesMethod.invoke(changesFinder, jsonText);
+ assertEquals("List of RepoLocations obtained must be same", repository, repoLocations);
+ } catch (CodeQualityMetricsException | InstantiationException | IllegalAccessException |
+ NoSuchMethodException |
+ InvocationTargetException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ });
+ }
+
+ @Test
+ public void testSavePrNumberAndRepoName() throws CodeQualityMetricsException {
+ String jsonText = GithubApiCallerUtils.callSearchIssueApi
+ ("0015c02145c8ec6d3bba433f2fb5e850e1d25846", githubToken);
+ Map> expectedPrNoWithRepoName = new HashMap<>();
+ Set expectedPrSet = new HashSet<>();
+ expectedPrSet.add(656);
+ expectedPrSet.add(657);
+ expectedPrNoWithRepoName.put("wso2/carbon-apimgt", expectedPrSet);
+ try {
+ Method savePrNumberAndRepoNameMethod = reviewAnalyserClass.getDeclaredMethod
+ ("savePrNumberAndRepoName", String.class);
+ savePrNumberAndRepoNameMethod.setAccessible(true);
+ Object reviewAnalyser = reviewAnalyserClass.newInstance();
+ @SuppressWarnings("unchecked")
+ Map> actualPrNoWithRepoName2 = (Map>)
+ savePrNumberAndRepoNameMethod.invoke(reviewAnalyser, jsonText);
+ assertThat(actualPrNoWithRepoName2, is(expectedPrNoWithRepoName));
+ } catch (IllegalAccessException | InstantiationException | InvocationTargetException |
+ NoSuchMethodException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ }
+
+ @Test
+ public void testObtainRepoNamesForCommitHashesForAuthorNames() throws CodeQualityMetricsException {
+ List commitHash1 = new ArrayList<>();
+ commitHash1.add("bba8ce79cd3373445e21dd12deffae1a7b48dca9");
+ commitHash1.add("1c0e28ca181a08398efbc8ba8e984d8800e23c95");
+ commitHash1.add("a8ddc56575ede78c6a1882df20789bb2cc04022c");
+ Set expectedAuthorName1 = new HashSet<>();
+ expectedAuthorName1.add("ruchiraw");
+ obtainRepoNamesForCommitHashes(commitHash1, expectedAuthorName1);
+
+ List commitHash2 = new ArrayList<>();
+ commitHash2.add("2b1d973d089ebc3af3b9e7b893f48cf905758cf4");
+ commitHash2.add("eaa45529cbabc5f30a2ffaa4781821ad0a5223ab");
+ Set expectedAuthorName2 = new HashSet<>();
+ expectedAuthorName2.add("Chamila");
+ expectedAuthorName2.add("lalaji");
+ expectedAuthorName2.add("Amila De Silva");
+ expectedAuthorName2.add("Lakmali");
+ obtainRepoNamesForCommitHashes(commitHash2, expectedAuthorName2);
+ }
+
+ private void obtainRepoNamesForCommitHashes(List commitHash, Set expectedAuthorName) {
+ try {
+ Field authorNamesField = changesFinderClass.getDeclaredField("authorNames");
+ Method obtainRepoNamesForCommitHashesMethod = changesFinderClass.getDeclaredMethod
+ ("obtainRepoNamesForCommitHashes", String.class, List.class);
+ Object changesFinder = changesFinderClass.newInstance();
+ obtainRepoNamesForCommitHashesMethod.invoke(changesFinder, githubToken, commitHash);
+ @SuppressWarnings("unchecked")
+ Set actualAuthorNames = (Set) authorNamesField.get(changesFinder);
+ assertThat(actualAuthorNames.size(), is(expectedAuthorName.size()));
+ assertThat(actualAuthorNames, is(expectedAuthorName));
+ } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | NoSuchFieldException |
+ InvocationTargetException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ }
+
+ @Test
+ public void testSaveReviewers() {
+ Map> prNoWithRepoName1 = new HashMap<>();
+ Set prNumberSet1 = new HashSet<>();
+ prNumberSet1.add(656);
+ prNumberSet1.add(657);
+ prNoWithRepoName1.put("wso2/carbon-apimgt", prNumberSet1);
+ // since no reviewers for pull requests 656,657
+ List expectedApprovedReviewers1 = Collections.emptyList();
+ List expectedCommentedReviewers1 = Collections.emptyList();
+ testSaveReviewersForPrs(prNoWithRepoName1, expectedApprovedReviewers1,
+ expectedCommentedReviewers1);
+ Map> prNoWithRepoName2 = new HashMap<>();
+ Set prNumberSet2 = new HashSet<>();
+ prNumberSet2.add(885);
+ prNoWithRepoName2.put("wso2/product-is", prNumberSet2);
+ List expectedApprovedReviewers2 = Collections.singletonList("darshanasbg");
+ List expectedCommentedReviewers2 = Collections.singletonList("isharak");
+ testSaveReviewersForPrs(prNoWithRepoName2, expectedApprovedReviewers2,
+ expectedCommentedReviewers2);
+ }
+
+ private void testSaveReviewersForPrs(Map> prNoWithRepoName1, List
+ expectedApprovedReviewers1, List expectedCommentedReviewers1) {
+ try {
+ Field approvedReviewersField = reviewAnalyserClass.getDeclaredField("approvedReviewers");
+ Field commentedReviewersField = reviewAnalyserClass.getDeclaredField("commentedReviewers");
+ approvedReviewersField.setAccessible(true);
+ commentedReviewersField.setAccessible(true);
+ Method saveReviewersMethod = reviewAnalyserClass.getDeclaredMethod("saveReviewers", Map.class,
+ String.class);
+ saveReviewersMethod.setAccessible(true);
+ Object reviewAnalyser = reviewAnalyserClass.newInstance();
+ saveReviewersMethod.invoke(reviewAnalyser, prNoWithRepoName1, githubToken);
+ @SuppressWarnings("unchecked")
+ Set actualApprovedReviewers = (Set) approvedReviewersField.get(reviewAnalyser);
+ @SuppressWarnings("unchecked")
+ Set actualCommentedReviewers = (Set) commentedReviewersField.get(reviewAnalyser);
+ assertThat("List of approved users ", actualApprovedReviewers, containsInAnyOrder
+ (expectedApprovedReviewers1.toArray()));
+ assertThat("List of commented users ", actualCommentedReviewers, containsInAnyOrder
+ (expectedCommentedReviewers1.toArray()));
+ } catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException |
+ NoSuchFieldException e) {
+ logger.error(e.getMessage(), e.getCause());
+ }
+ }
+}
diff --git a/src/test/java/com/wso2/code/quality/metrics/GithubSdkClientTest.java b/src/test/java/com/wso2/code/quality/metrics/GithubSdkClientTest.java
new file mode 100644
index 0000000..3720b76
--- /dev/null
+++ b/src/test/java/com/wso2/code/quality/metrics/GithubSdkClientTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+import com.wso2.code.quality.metrics.exceptions.CodeQualityMetricsException;
+import org.hamcrest.collection.IsMapContaining;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+
+/**
+ * A class used to getFilesChanged method of the GithubSdkClient class
+ *
+ * @since 1.0.0
+ */
+public class GithubSdkClientTest {
+ private static SdkGitHubClient sdkGitHubClient;
+
+ @BeforeClass
+ public static void setupTheEnvironment() throws CodeQualityMetricsException {
+ String githubToken = new Token().getGithubToken();
+ sdkGitHubClient = new SdkGitHubClient(githubToken);
+ }
+
+ @Test
+ public void testGetFilesChanged() throws CodeQualityMetricsException {
+ Map actualFileNamesAndPatches = sdkGitHubClient.getFilesChanged
+ ("wso2/carbon-apimgt", "eaa45529cbabc5f30a2ffaa4781821ad0a5223ab");
+ assertThat(actualFileNamesAndPatches.size(), is(4));
+ assertThat(actualFileNamesAndPatches, IsMapContaining.hasKey("components/sso-hostobject/org.wso2.carbon" +
+ ".hostobjects.sso/src/main/java/org/wso2/carbon/hostobjects/sso/SAMLSSORelyingPartyObject.java"));
+ assertThat(actualFileNamesAndPatches, IsMapContaining.hasKey("components/sso-hostobject/org.wso2.carbon." +
+ "hostobjects.sso/src/main/java/org/wso2/carbon/hostobjects/sso/internal/SessionInfo.java"));
+ assertThat(actualFileNamesAndPatches, IsMapContaining.hasKey("features/apimgt/org.wso2.carbon.apimgt." +
+ "publisher.feature/src/main/resources/publisher/site/themes/wso2/templates/sso/logout/template.jag"));
+ assertThat(actualFileNamesAndPatches, IsMapContaining.hasKey("features/apimgt/org.wso2.carbon.apimgt." +
+ "store.feature/src/main/resources/store/site/themes/wso2/templates/sso/logout/template.jag"));
+ }
+}
diff --git a/src/test/java/com/wso2/code/quality/metrics/Token.java b/src/test/java/com/wso2/code/quality/metrics/Token.java
new file mode 100644
index 0000000..dffcf1b
--- /dev/null
+++ b/src/test/java/com/wso2/code/quality/metrics/Token.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.wso2.code.quality.metrics;
+
+import com.wso2.code.quality.metrics.exceptions.CodeQualityMetricsException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.Properties;
+
+/**
+ * This class is used for providing github and WSO2 PMT access tokens
+ *
+ * @since 1.0.0
+ */
+public class Token {
+ private String pmtToken;
+ private String githubToken;
+
+ public Token() throws CodeQualityMetricsException {
+ Properties defaultProperties = new Properties();
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ try (InputStream inputStream = classLoader.getResourceAsStream("tokens.properties")) {
+ defaultProperties.load(inputStream);
+ byte[] pmtTokenInBytes = Base64.getDecoder().decode(defaultProperties.getProperty("pmtToken"));
+ pmtToken = new String(pmtTokenInBytes, StandardCharsets.UTF_8);
+ byte[] githubTokenInBytes = Base64.getDecoder().decode(defaultProperties.getProperty("githubToken"));
+ githubToken = new String(githubTokenInBytes, StandardCharsets.UTF_8);
+ } catch (IOException e) {
+ throw new CodeQualityMetricsException("IO exception occurred when loading the inputstream to the " +
+ "properties object", e);
+ }
+ }
+
+ public String getPmtToken() {
+ return pmtToken;
+ }
+
+ public String getGithubToken() {
+ return githubToken;
+ }
+}
diff --git a/src/test/resources/patchStrings/patchString1.txt b/src/test/resources/patchStrings/patchString1.txt
new file mode 100644
index 0000000..67ca085
--- /dev/null
+++ b/src/test/resources/patchStrings/patchString1.txt
@@ -0,0 +1,138 @@
+@@ -819,9 +819,11 @@ public static void jsFunction_invalidateSessionBySessionId(Context cx, Scriptabl
+ SAMLSSORelyingPartyObject relyingPartyObject = (SAMLSSORelyingPartyObject) thisObj;
+ String sessionId = (String) args[0];
+ String sessionIndex = relyingPartyObject.getSessionIndex(sessionId);
+- relyingPartyObject.handleLogout(sessionIndex);
+-
+-
++ if (sessionIndex != null) {
++ relyingPartyObject.handleLogout(sessionIndex);
++ } else {
++ relyingPartyObject.handleLogoutBySessionId(sessionId);
++ }
+ }
+
+ /**
+@@ -901,12 +903,14 @@ public static void jsFunction_setSessionAuthenticated(Context cx, Scriptable thi
+ log.debug("Encoded SAML token that is set on session info is " + args[1]);
+ }
+ sessionInfo.setSamlToken((String) args[1]);//We expect an encoded SamlToken here.
++ SessionHostObject sho = (SessionHostObject) args[2];
++ sessionInfo.setSessionHostObject(sho);
+ relyingPartyObject.addSessionInfo(sessionInfo);
+ //relyingPartyObject.addSessionInfo(sessionIndex, SAMLSSORelyingPartyObject.sho);
+
+- SessionHostObject sho = (SessionHostObject) args[2];
+- relyingPartyObject.addSessionInfo(sessionIndex, sho);
+-
++ if (sessionIndex != null) {
++ relyingPartyObject.addSessionToSessionIndexMap(sessionIndex, sho);
++ }
+ }
+
+ /**
+@@ -1078,21 +1082,26 @@ private void invalidateSessionBySessionId(String sessionId) {
+ }
+
+ private boolean isSessionIdExists(String sessionId) throws Exception {
+- Iterator>> iterator = sessionIndexMap.entrySet().iterator();
+- while (iterator.hasNext()) {
+- Map.Entry> entry = iterator.next();
++ for (Map.Entry> entry : sessionIndexMap.entrySet()) {
+ Set sessions = new HashSet(entry.getValue());
+ for (SessionHostObject session : sessions) {
+ Object[] args = new Object[0];
+- if (session != null && sessionId.equals(SessionHostObject.jsFunction_getId(null, session, args, null))) {
++ if (session != null && sessionId
++ .equals(SessionHostObject.jsFunction_getId(null, session, args, null))) {
+ if (log.isDebugEnabled()) {
+ log.debug("Session Id exists:" + SessionHostObject.jsFunction_getId(null, session, args, null));
+ }
+ return true;
+ }
+ }
+- //}
+ }
++ log.debug("Session Id does not exist in sessionIndexMap. Now searching in sessionIdMap.");
++ if (getSessionInfo(sessionId) != null) {
++ log.debug("Session Id exists in sessionIdMap : " + sessionId);
++ return true;
++ }
++
++ log.debug("Session Id does not exist in sessionIdMap : " + sessionId);
+ return false;
+ }
+
+@@ -1140,17 +1149,7 @@ private static String getSSOSamlDeflateProperty(SAMLSSORelyingPartyObject relyin
+ }
+ }
+
+- /**
+- * Add current browser session with session index.
+- */
+- private void addSessionInfo(String sessionIndex, Set sho) {
+- if (log.isDebugEnabled()) {
+- log.debug("Added session index:" + sessionIndex);
+- }
+- sessionIndexMap.put(sessionIndex, sho);
+- }
+-
+- private void addSessionInfo(String sessionIndex, SessionHostObject sho) {
++ private void addSessionToSessionIndexMap(String sessionIndex, SessionHostObject sho) {
+ if (log.isDebugEnabled()) {
+ log.debug("Added session index:" + sessionIndex);
+ }
+@@ -1162,7 +1161,6 @@ private void addSessionInfo(String sessionIndex, SessionHostObject sho) {
+ sessionSet.add(sho);
+ sessionIndexMap.put(sessionIndex, sessionSet);
+ }
+-
+ }
+
+ /**
+@@ -1276,6 +1274,14 @@ public void handleLogout(String sessionIndex) {
+ }
+ }
+
++ public void handleLogoutBySessionId(String sessionId) {
++ clearSessionDataFromSessionId(sessionId);
++
++ if (log.isDebugEnabled()) {
++ log.debug("Cleared authenticated session id:" + sessionId + "in handle logout method");
++ }
++ }
++
+ public void handleClusterLogout(String sessionIndex) {
+ if (log.isDebugEnabled()) {
+ log.debug("session index map value:" + sessionIndexMap);
+@@ -1331,6 +1337,31 @@ private void clearSessionData(String sessionIndex) {
+ }
+ }
+
++ private void clearSessionDataFromSessionId(String sessionIdToClear) {
++ SessionInfo sessionInfo = getSessionInfo(sessionIdToClear);
++ if (sessionInfo != null) {
++ SessionHostObject sessionHostObject = sessionInfo.getSessionHostObject();
++ if (sessionHostObject != null) {
++ try {
++ Object[] args = new Object[0];
++ SessionHostObject.jsFunction_invalidate(null, sessionHostObject, args, null);
++ } catch (Exception ex) {
++ //catches generic exception since we do not need to stop the
++ // process due to invalidating one single session
++ if (ex.getMessage().contains("Session already invalidated")) { // can be ignored
++ log.info(ex.getMessage());
++ } else {
++ //log the error and continues since this does not brake the flow.
++ log.error("Error while invalidating the session " + sessionIdToClear, ex);
++ }
++ }
++ }
++ }
++ ssho.invalidateSessionBySessionId(sessionIdToClear);
++ if (log.isDebugEnabled()) {
++ log.debug("Cleared authenticated session index:" + sessionIdToClear + "in handle logout method");
++ }
++ }
+
+ public void sendSessionInvalidationClusterMessage(String sessionIndex) {
diff --git a/src/test/resources/patchStrings/patchString2.txt b/src/test/resources/patchStrings/patchString2.txt
new file mode 100644
index 0000000..52c64f6
--- /dev/null
+++ b/src/test/resources/patchStrings/patchString2.txt
@@ -0,0 +1,29 @@
+@@ -16,11 +16,14 @@
+
+ package org.wso2.carbon.hostobjects.sso.internal;
+
++import org.jaggeryjs.hostobjects.web.SessionHostObject;
++
+ public class SessionInfo {
+ private String sessionId;
+ private String loggedInUser;
+ private String sessionIndex;
+ private String samlToken;
++ private SessionHostObject sessionHostObject;
+
+ public SessionInfo(String sessionId) {
+ this.sessionId = sessionId;
+@@ -57,4 +60,12 @@ public String getSamlToken() {
+ public void setSamlToken(String samlToken) {
+ this.samlToken = samlToken;
+ }
++
++ public void setSessionHostObject(SessionHostObject sessionHostObject) {
++ this.sessionHostObject = sessionHostObject;
++ }
++
++ public SessionHostObject getSessionHostObject() {
++ return sessionHostObject;
++ }
+ }
+\ No newline at end of file
\ No newline at end of file