-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from Minjung-Baek/master
Add feature for code Metrics
- Loading branch information
Showing
166 changed files
with
40,351 additions
and
585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"codeMetricThreshold":{ | ||
"cc":{ | ||
"moderate":"25", | ||
"caution":"50" | ||
}, | ||
"sloc":"500", | ||
"class":"20", | ||
"method":"50" | ||
}, | ||
"codeMetricQuantity":"3" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var ccListApp = angular.module('ccListApp', ['ngRoute', 'ngGrid', 'ngAnimate', 'ui.bootstrap', 'ngSanitize']); | ||
|
||
ccListApp.config(function($routeProvider){ | ||
$routeProvider | ||
.when('/', { | ||
controller: 'ccListCtrl', | ||
templateUrl: 'ccListView.html' | ||
}) | ||
.when("/:fileName/",{ | ||
controller: 'ccListCtrlForFile', | ||
templateUrl: 'ccListViewForFile.html' | ||
}) | ||
; | ||
$routeProvider.otherwise({"redirectTo":"/"}) | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
ccListApp.controller('ccListCtrl',function($scope, $http, $location, $log){ | ||
"use strict"; | ||
var rowHeight = 28; | ||
var headerHeight = 30; | ||
|
||
$scope.ccListForFile = []; | ||
|
||
$scope.isTooHigh = function(value){ | ||
return value > 20; | ||
}; | ||
|
||
$http.get('/api/v1/codeMetrics/ccList', { | ||
}).then(function(result){ | ||
if(result && result.data){ | ||
$scope.ccList=result.data.result; | ||
} | ||
}, function (results){ | ||
$log.info('Error code:' + results.status +';'); | ||
}); | ||
|
||
angular.element('#showLoading').hide(); | ||
$scope.ccListGridOptions = { | ||
data: 'ccList', | ||
multiSelect : false, | ||
enablePaging: true, | ||
showFooter: true, | ||
enablePinning: true, | ||
enableColumnResize: true, | ||
enableColumnReordering: true, | ||
enableRowSelection: true, | ||
enableRowReordering: true, | ||
totalServerItems: 'allCCListCount', | ||
headerRowHeight: headerHeight, | ||
rowHeight: rowHeight, | ||
columnDefs:[ | ||
{field:"fileName", displayName:'File', width: 200, cellClass:'textAlignCenter'}, | ||
{field:"modulePath", displayName:'Module', cellClass:'textAlignLeft'}, | ||
{field:"metricValue", displayName:'CC', cellClass:'textAlignCenter', cellTemplate: '<div ng-class="{redBG: isTooHigh(row.getProperty(col.field))}"><div class="ngCellText">{{row.getProperty(col.field)}}</div></div>'} | ||
] | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
ccListApp.controller('ccListCtrlForFile',function($scope, $http, $location, $routeParams, $log){ | ||
"use strict"; | ||
|
||
var rowHeight = 28; | ||
var headerHeight = 30; | ||
|
||
$scope.ccListForFile = []; | ||
|
||
$http.get('/api/v1/codeMetrics/ccList', { | ||
}).then(function(result){ | ||
if(result && result.data){ | ||
$scope.ccListForFile=result.data.result; | ||
} | ||
}, function (results){ | ||
$log.info('Error code:' + results.status +';'); | ||
}); | ||
|
||
angular.element('#showLoading').hide(); | ||
|
||
$scope.ccListGridOptionsForFile = { | ||
data: 'ccListForFile', | ||
multiSelect : false, | ||
enablePaging: true, | ||
showFooter: true, | ||
enablePinning: true, | ||
enableColumnResize: true, | ||
enableColumnReordering: true, | ||
enableRowSelection: true, | ||
enableRowReordering: true, | ||
totalServerItems: 'allCCListCount', | ||
headerRowHeight: headerHeight, | ||
rowHeight: rowHeight, | ||
columnDefs:[ | ||
{field:"fileName", displayName:'fileName', width: 150, cellClass:'textAlignCenter'}, | ||
{field:"modulePath", displayName:'modulePath', width: 300, cellClass:'textAlignLeft'}, | ||
{field:"metricValue", displayName:'CC Value', width: 100, cellClass:'textAlignCenter'} | ||
] | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!DOCTYPE html> | ||
<font face="Tahoma, Lucida Grande, Helvetica, Arial, sans-serif"> | ||
|
||
<head> | ||
<link rel="stylesheet" href="../defect/asset/css/prettify.css" /> | ||
<script src="../defect/asset/js/prettify.js"></script> | ||
<script type="text/javascript"> | ||
$(function() { | ||
|
||
window.prettyPrint && prettyPrint(); | ||
$('#id-check-horizontal').removeAttr('checked').on('click', function(){ | ||
$('#dt-list-1').toggleClass('dl-horizontal').prev().html(this.checked ? '<dl class="dl-horizontal">' : '<dl>'); | ||
}); | ||
|
||
}) | ||
</script> | ||
</head> | ||
<div class = "ccListDiv"> | ||
<div class="row"> | ||
<div class="col-xs-6"> | ||
<div class="ccList" id="ccListGrid" ng-grid="ccListGridOptions"> | ||
|
||
</div> | ||
</div> | ||
<div class="col-xs-6"> | ||
<br><font size="5"><span class="glyphicon glyphicon-subtitles"></span> What is the Cyclomatic Complexity(CC) ?</font> | ||
<br> | ||
Cyclomatic complexity is a software metric (measurement), used to indicate the complexity of a program.<br> | ||
It is a quantitative measure of the number of linearly independent paths through a program's code. | ||
<br><br><br><font size="5"><span class="glyphicon glyphicon-tag"></span> How to REDUCE Cyclomatic Complexity(CC) ?</font> | ||
<br> | ||
1. Add private methods with meaningful names to remove duplicate code<br> | ||
2. Add private methods with meaningful names to wrap any functionalities that are not directly related to business logic such as<br> | ||
<br><br><font size="5"><span class="glyphicon glyphicon-check"></span> SAMPLE CODE </font> | ||
<br><br> | ||
<pre class="prettyprint linenums warning"> | ||
@ Bad Code | ||
public ResponseObject generateResponseObject(String route) { | ||
ResponseObject responseObject; | ||
if (route.equals("time")) { | ||
responseObject = new TimeResponse(); | ||
} else if (route.equals("echo")) { | ||
responseObject = new EchoResponse(); | ||
} else if (route.equals("redirect")) { | ||
responseObject = new RedirectResponse(); | ||
} else if (route.equals("file")) { | ||
responseObject = new FileResponse(); | ||
} else { | ||
responseObject = new FormResponse(); | ||
} | ||
return responseObject; | ||
} | ||
</pre> | ||
|
||
<br><br> | ||
<pre class="prettyprint linenums correct"> | ||
@ Good Code | ||
public ResponseObject generateResponseObject(HashMap<String, ResponseObject> routes) { | ||
ResponseObject responseObject; | ||
String route = httpRequestContent.get("route"); | ||
responseObject = routes.get(route); | ||
return responseObject; | ||
} | ||
</pre> | ||
</div> | ||
</div> | ||
</font> |
61 changes: 61 additions & 0 deletions
61
project/dexter-server/public/ccList/ccListViewForFile.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<!DOCTYPE html> | ||
<font face="Tahoma, Lucida Grande, Helvetica, Arial, sans-serif"> | ||
|
||
<head> | ||
<link rel="stylesheet" href="../defect/asset/css/prettify.css" /> | ||
<script src="../defect/asset/js/prettify.js"></script> | ||
<script type="text/javascript"> | ||
$(function() { | ||
|
||
window.prettyPrint && prettyPrint(); | ||
$('#id-check-horizontal').removeAttr('checked').on('click', function(){ | ||
$('#dt-list-1').toggleClass('dl-horizontal').prev().html(this.checked ? '<dl class="dl-horizontal">' : '<dl>'); | ||
}); | ||
|
||
}) | ||
</script> | ||
</head> | ||
|
||
<div class = "ccListDiv"> | ||
<h3 id="title">For Each File / {{fileNameForCC}}</h3> | ||
<div class="row"> | ||
|
||
<div class="col-xs-6"> | ||
<div class="ccList" id="ccListGridForFile" ng-grid="ccListGridOptionsForFile"> | ||
|
||
</div> | ||
</div> | ||
<div class="col-xs-6"> | ||
<br><font size="5"><span class="glyphicon glyphicon-subtitles"></span> What is the Cyclomatic Complexity(CC) ?</font> | ||
<br> | ||
Cyclomatic complexity is a software metric (measurement), used to indicate the complexity of a program.<br> | ||
It is a quantitative measure of the number of linearly independent paths through a program's code. | ||
<br><br><br><font size="5"><span class="glyphicon glyphicon-tag"></span> How to REDUCE Cyclomatic Complexity(CC) ?</font> | ||
<br> | ||
1. Add private methods with meaningful names to remove duplicate code<br> | ||
2. Add private methods with meaningful names to wrap any functionalities that are not directly related to business logic such as<br> | ||
<br><br><font size="5"><span class="glyphicon glyphicon-check"></span> SAMPLE CODE </font> | ||
<br><br> | ||
<pre class="prettyprint linenums warning"> | ||
@ Bad Code | ||
Map<String, Float> multipliers = new HashMap<String, Float>(); | ||
map.put("S", 60 * 60); | ||
map.put("ms", 60 * 60 * 1000); | ||
map.put("m", 60); | ||
map.put("H", 1); | ||
map.put("d", 1.0 / 24); | ||
map.put("w", 1.0 / (24 * 7)); | ||
</pre> | ||
|
||
<br><br> | ||
<pre class="prettyprint linenums correct"> | ||
@ Good Code | ||
Pattern foo = Pattern.compile(".*(\\d+)\\s*(\\w+)"); | ||
Matcher bar = foo.matcher(sValue); | ||
if(bar.matches()) { | ||
return (long) (Double.parseDouble(bar.group(1)) * multipliers.get(bar.group(2); | ||
} | ||
</pre> | ||
</div> | ||
</div> | ||
</font> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!DOCTYPE html> | ||
<html ng-app="ccListApp"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title id = "indexAdminTitle">ccListApp</title> | ||
<link href="../css/jq/jquery-ui-1.9.2.min.css" rel="stylesheet" type="text/css" /> | ||
<link rel="stylesheet" type="text/css" href="../css/style.css" /> | ||
<link rel="stylesheet" type="text/css" href="../css/ng/ng-table.min.css" /> | ||
<link rel="stylesheet" type="text/css" href="../css/ng/ng-table.css" /> | ||
<link rel="stylesheet" type="text/css" href="../css/bootstrap.css" /> | ||
|
||
<link rel="stylesheet" type="text/css" href="../css/jq/layout-default.css" /> | ||
<link rel="stylesheet" type="text/css" href="../css/ng/ng-grid.min.css" /> | ||
|
||
<script src="../js/jq/jquery-1.11.1.min.js"></script> | ||
<script src="../js/jq/jquery-ui-1.9.2.min.js"></script> | ||
<script src="../js/jq/jquery.layout-latest.js"></script> | ||
<script src="../js/ng/angular.min.js"></script> | ||
<script src="../js/ng/angular-animate.min.js"></script> | ||
<script src="../js/ng/angular-route.min.js"></script> | ||
<script src="../js/ng/angular-resource.min.js"></script> | ||
<script src="../js/ng/angular-sanitize.min.js"></script> | ||
<script src="../js/ng/ng-grid-2.0.11.min.js"></script> | ||
<script src="../js/ng/ui-bootstrap-tpls-0.11.0.min.js"></script> | ||
<script src="../js/common.js"></script> | ||
|
||
<script src="../js/bootstrap-button.js"></script> | ||
<!--script src="../util/util/dexter-util.js"></script--> | ||
|
||
<!-- | ||
* Sets this component properties. | ||
* | ||
* @public | ||
* @function : checkBrowser | ||
* @author [email protected] | ||
* | ||
* @detail description | ||
* Dexter Web is supported below browser : [opera|chrome|safari|firefox|msie] | ||
* If the developers are use another browser, we need to show the "/error/NotSupportedBrowser.html" page. | ||
* @since 1.11.19 | ||
--> | ||
<script> | ||
checkBrowser(); | ||
$(document).ready(function(){ | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<div ng-include="'../header.html'"></div> | ||
<div ng-view=""></div> | ||
<div ng-include="'../footer.html'"></div> | ||
|
||
<script src="ccListApp.js"></script> | ||
<script src="ccListCtrl.js"></script> | ||
<script src="ccListCtrlForFile.js"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var classInfoApp = angular.module('classInfoApp', ['ngRoute', 'ngGrid', 'ngAnimate', 'ui.bootstrap', 'ngSanitize']); | ||
|
||
classInfoApp.config(function($routeProvider){ | ||
$routeProvider.when('/', { | ||
controller: 'classInfoCtrl', | ||
templateUrl: 'classInfoView.html' | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
classInfoApp.controller('classInfoCtrl',function($scope, $http, $location){ | ||
"use strict"; | ||
var rowHeight = 28; | ||
var headerHeight = 30; | ||
|
||
$scope.ccList = [ | ||
{id:'1'}, | ||
{id:'2'}, | ||
{id:'3'} | ||
]; | ||
|
||
angular.element('#showLoading').hide(); | ||
|
||
$scope.classInfoGridOptions = { | ||
data: 'ccList', | ||
multiSelect : false, | ||
enablePaging: true, | ||
showFooter: true, | ||
enablePinning: true, | ||
enableColumnResize: true, | ||
enableColumnReordering: true, | ||
enableRowSelection: true, | ||
enableRowReordering: true, | ||
totalServerItems: 'allCCListCount', | ||
headerRowHeight: headerHeight, | ||
rowHeight: rowHeight, | ||
columnDefs:[ | ||
{field:"id", displayName:'ID', width: 350, cellClass:'textAlignCenter'}, | ||
{field:"id", displayName:'ID2', width: 350, cellClass:'textAlignCenter'} | ||
] | ||
}; | ||
}) |
Oops, something went wrong.