Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/main/java/hudson/plugins/nsiq/NSiqBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import net.sf.json.JSONObject;

import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
Expand Down Expand Up @@ -75,7 +74,7 @@ private String[] getSourceDirs() {
for (String dir : splitted) {
String trim = dir.trim();

if (StringUtils.isNotEmpty(trim)) {
if ((trim != null && trim.length() > 0)) {
result.add(trim);
}
}
Expand All @@ -95,7 +94,7 @@ public BuildStepDescriptor<Builder> getDescriptor() {
* 프로젝트 빌드가 완료된 후, {@link Builder}가 실제 수행하는 메소드이다.
*/
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
if (StringUtils.isEmpty(DESCRIPTOR.getNsiqPath())) {
if ((DESCRIPTOR.getNsiqPath() == null || DESCRIPTOR.getNsiqPath().length() == 0)) {
listener.getLogger().println("[" + Constant.DISPLAY_NAME + "] " + "N'SIQ Collector path is not configured...");
return true;
}
Expand All @@ -115,7 +114,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
args.add("-c", NSiqUtil.getComplexityFile(moduleRoot).getRemote());

// 파일 필터 직접 설정이 되어 있으면, 파일 필터를 실행시 지정한다.
if (fileFilter != null && StringUtils.isNotEmpty(fileFilter.trim())) {
if (fileFilter != null && (fileFilter.trim() != null && fileFilter.trim().length() > 0)) {
FilePath filterFilePath = new FilePath(moduleRoot, fileFilter.trim());

if (filterFilePath.exists()) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/hudson/plugins/nsiq/NSiqTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import javax.servlet.ServletException;

import org.apache.commons.lang.mutable.MutableInt;
import java.util.concurrent.atomic.AtomicInteger;
import org.jfree.chart.JFreeChart;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
Expand Down Expand Up @@ -150,18 +150,18 @@ private void parseSummary(List<NSiqResult> nsiqResults) {
int comp = 0;
int totalLoc = 0;
int codeLoc = 0;
Map<FileType, MutableInt> locPerType = new HashMap<FileType, MutableInt>();
Map<FileType, AtomicInteger> locPerType = new HashMap<FileType, AtomicInteger>();

for (NSiqResult nsiq : nsiqResults) {
totalLoc += nsiq.getTotalLoc();
codeLoc += nsiq.getCodeLoc();

MutableInt eachLocPerType = locPerType.get(nsiq.geteType());
AtomicInteger eachLocPerType = locPerType.get(nsiq.geteType());
if (eachLocPerType == null) {
eachLocPerType = new MutableInt();
eachLocPerType = new AtomicInteger();
locPerType.put(nsiq.geteType(), eachLocPerType);
}
eachLocPerType.add(nsiq.getCodeLoc());
eachLocPerType.addAndGet(nsiq.getCodeLoc());

if (nsiq.getFunctions() == null) {
continue;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/hudson/plugins/nsiq/NSiqUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.Map;
import java.util.Map.Entry;

import org.apache.commons.lang.mutable.MutableInt;
import java.util.concurrent.atomic.AtomicInteger;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
Expand Down Expand Up @@ -185,10 +185,10 @@ public static JFreeChart createDistrubutionChart(CategoryDataset dataset, String
return chart;
}

public static Map<FileType, Integer> convertLangDistMap(Map<FileType, MutableInt> locPerType) {
public static Map<FileType, Integer> convertLangDistMap(Map<FileType, AtomicInteger> locPerType) {
Map<FileType, Integer> langDistMap = new HashMap<FileType, Integer>();
for (Entry<FileType, MutableInt> entry : locPerType.entrySet()) {
langDistMap.put(entry.getKey(), entry.getValue().toInteger());
for (Entry<FileType, AtomicInteger> entry : locPerType.entrySet()) {
langDistMap.put(entry.getKey(), entry.getValue().get());
}
return langDistMap;
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/hudson/plugins/nsiq/model/Complexity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import hudson.plugins.nsiq.NSiqAware;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
*
Expand Down Expand Up @@ -111,7 +109,12 @@ public int getLowDist() {

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
return "Complexity["
+ "function=" + function
+ ",complexity=" + complexity
+ ",totalLoc=" + totalLoc
+ ",codeLoc=" + codeLoc
+ "]";
}

public int compareTo(Complexity complexity) {
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/hudson/plugins/nsiq/model/Loc.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package hudson.plugins.nsiq.model;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
*
Expand Down Expand Up @@ -57,6 +55,12 @@ public void setCodeLoc(int codeLoc) {

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
return "Loc["
+ "target=" + target
+ ",type=" + type
+ ",file=" + file
+ ",totalLoc=" + totalLoc
+ ",codeLoc=" + codeLoc
+ "]";
}
}
13 changes: 10 additions & 3 deletions src/main/java/hudson/plugins/nsiq/model/NSiqResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import java.util.List;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
*
Expand Down Expand Up @@ -100,7 +98,16 @@ public int getLowCount() {

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
return "NSiqResult["
+ "eType=" + eType
+ ",type=" + type
+ ",dir=" + dir
+ ",file=" + file
+ ",complexity=" + complexity
+ ",functions=" + functions
+ ",totalLoc=" + totalLoc
+ ",codeLoc=" + codeLoc
+ "]";
}

@Override
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/hudson/plugins/nsiq/model/NSiqSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import java.util.Map;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
*
Expand Down Expand Up @@ -80,7 +78,15 @@ public String getAverageComplexity() {

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
return "NSiqSummary["
+ "total=" + total
+ ",high=" + high
+ ",low=" + low
+ ",complexity=" + complexity
+ ",totalLoc=" + totalLoc
+ ",codeLoc=" + codeLoc
+ ",locPerType=" + locPerType
+ "]";
}

public void setLocPerType(Map<FileType, Integer> locPerType) {
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/hudson/plugins/nsiq/parser/NSiqResultParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.mutable.MutableInt;
import java.util.concurrent.atomic.AtomicInteger;

/**
*
Expand All @@ -40,7 +39,7 @@ public NSiqResultParser(List<Loc> locList, List<Complexity> complexityList) {
private String getDir(String filename, String target) {
File file = new File(filename);
String dir = file.getParent();
return StringUtils.isEmpty(dir) ? "[" + target + "]" : dir;
return (dir == null || dir.length() == 0) ? "[" + target + "]" : dir;
}

/**
Expand Down Expand Up @@ -81,19 +80,19 @@ public List<NSiqResult> parse() {
int comp = 0;
int totalLoc = 0;
int codeLoc = 0;
Map<FileType, MutableInt> locPerType = new HashMap<FileType, MutableInt>();
Map<FileType, AtomicInteger> locPerType = new HashMap<FileType, AtomicInteger>();

for (Loc loc : locList) {
totalLoc += loc.getTotalLoc();
codeLoc += loc.getCodeLoc();
result.add(getNSiqResult(loc));

MutableInt eachLocPerType = locPerType.get(loc.getType());
AtomicInteger eachLocPerType = locPerType.get(loc.getType());
if (eachLocPerType == null) {
eachLocPerType = new MutableInt();
eachLocPerType = new AtomicInteger();
locPerType.put(loc.getType(), eachLocPerType);
}
eachLocPerType.add(loc.getCodeLoc());
eachLocPerType.addAndGet(loc.getCodeLoc());
}

for (Complexity complexity : complexityList) {
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/hudson/plugins/nsiq/NSiqTargetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import java.io.IOException;

import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;

Expand All @@ -28,7 +27,7 @@ private String join(String[] array, String delimiter) {

String result = sb.toString();

if (StringUtils.isEmpty(result)) {
if ((result == null || result.length() == 0)) {
return result;
}

Expand Down