Skip to content

Commit

Permalink
FIX CR LF problem when reading repo_info files.
Browse files Browse the repository at this point in the history
  • Loading branch information
gavelino committed Sep 11, 2015
1 parent 2b41ea1 commit bae2ba8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gittruckfactor/scripts/linguist_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ path=$1
now=$(date)
echo -e \\n$now: BEGIN linguist script\\n

ruby linguist.rb $path > $path"linguistfiles.log"
ruby linguist.rb $path > $path/linguistfiles.log

echo -e "linguistfile.log was generated in $path folder: \\n"
now=$(date)
Expand Down
10 changes: 8 additions & 2 deletions gittruckfactor/src/aserg/gtf/GitTruckFactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public static void main(String[] args) {
Map<String, List<LineInfo>> modulesInfo;
try {
filesInfo = FileInfoReader.getFileInfo("repo_info/filtered-files.txt");
// for (Entry<String, List<LineInfo>> entry : filesInfo.entrySet()) {
// LOGGER.info(entry.getKey() + ": Lines in filtered files: "+ filesInfo.size());
// }
} catch (IOException e) {
LOGGER.warn("Not possible to read repo_info/filtered-files.txt file. File filter step will not be executed!");
filesInfo = null;
Expand Down Expand Up @@ -145,8 +148,11 @@ private static void calculateTF(String repositoryPath,

List<NewFileInfo> files = fileExtractor.execute();
files = linguistExtractor.setNotLinguist(files);
if(filesInfo != null)
applyFilterFiles(filesInfo.get(repositoryName), files);
if(filesInfo != null && filesInfo.size()>0)
if(filesInfo.containsKey(repositoryName))
applyFilterFiles(filesInfo.get(repositoryName), files);
else
LOGGER.warn("No filesInfo for " + repositoryName);

if(modulesInfo != null && modulesInfo.containsKey(repositoryName))
setModules(modulesInfo.get(repositoryName), files);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ private void printTruckMap(String repName, Map<Integer, Float> truckMap) {
}
}
private void printTF(String repName, Map<Integer, Float> truckMap) {
if (truckMap != null){
if (!truckMap.isEmpty()){
float coverage = truckMap.size() == 1 ? 0f : truckMap.get(tfAuthorInfo.size())*100;
System.out.format("TF = %d (coverage = %.2f%%)\nTF authors (Developer;Files;Percentage):\n", tfAuthorInfo.size(), coverage);
for (String tfInfo : tfAuthorInfo) {
System.out.println(tfInfo);
}
}
else
LOGGER.warn("No authorship information enough to calculate the TF. Verify the number of files and commit available after filter steps");
LOGGER.error("No authorship information enough to calculate the TF. Verify the number of files and commit available after filter steps");
}

}
6 changes: 4 additions & 2 deletions gittruckfactor/src/aserg/gtf/util/FileInfoReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import java.util.List;
import java.util.Map;

import com.google.common.io.LineReader;

public class FileInfoReader {

public static Map<String, List<LineInfo>> getFileInfo(String fileName) throws IOException{
Map<String, List<LineInfo>> fileInfoMap = new HashMap<String, List<LineInfo>>();
BufferedReader br = new BufferedReader(new FileReader(fileName));
CRLFLineReader lineReader = new CRLFLineReader(br);
LineReader lineReader = new LineReader(br);
String sCurrentLine;
String[] values;
int countcfs = 0;
Expand All @@ -30,7 +32,7 @@ public static Map<String, List<LineInfo>> getFileInfo(String fileName) throws IO
}
fileInfoMap.get(rep).add(new LineInfo(rep, Arrays.asList(values).subList(1, values.length)));
}
lineReader.close();
//lineReader.close();
return fileInfoMap;
}

Expand Down

0 comments on commit bae2ba8

Please sign in to comment.