diff --git a/pom.xml b/pom.xml index a0fc742..390512f 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - br.ufpe.cin.groundhog + br.ufpe.cin groundhog 0.1.0 jar diff --git a/src/java/main/br/ufpe/cin/groundhog/License.java b/src/java/main/br/ufpe/cin/groundhog/License.java index 563993b..62b239e 100644 --- a/src/java/main/br/ufpe/cin/groundhog/License.java +++ b/src/java/main/br/ufpe/cin/groundhog/License.java @@ -25,4 +25,8 @@ public String getName() { public String getEntireContent() { return entireContent; } + + public String toString() { + return name; + } } diff --git a/src/java/main/br/ufpe/cin/groundhog/parser/license/LicenseParser.java b/src/java/main/br/ufpe/cin/groundhog/parser/license/LicenseParser.java index f9ee95e..18fd49a 100644 --- a/src/java/main/br/ufpe/cin/groundhog/parser/license/LicenseParser.java +++ b/src/java/main/br/ufpe/cin/groundhog/parser/license/LicenseParser.java @@ -10,6 +10,13 @@ import com.google.common.collect.Lists; +/** + * Class that tries to find what is the project's license. + * This in a work in progress. May lead to misleading results. + * + * @author ghlp + * @since 0.1.0 + */ public class LicenseParser { private static Logger logger = LoggerFactory.getLogger(LicenseParser.class); @@ -29,26 +36,28 @@ public License parser() { logger.info("Running license parser.."); FileUtil filesUtils = FileUtil.getInstance(); - - for(File file: files) { - if(filesUtils.isTextFile(file)) { + + for (File file : files) { + if (filesUtils.isTextFile(file)) { String content = filesUtils.readAllLines(file); - - if(containsLicenseWord(content)) { + + if (containsLicenseWord(content)) { return extractLicense(content); } } } - - logger.info(String.format("No license found for project %s", root.getName())); + + logger.info(String.format("No license found for project %s", + root.getName())); return new License("unlincesed"); } private License extractLicense(String content) { - - for(String license: Licenses.names()) { - if(content.contains(license)) { - logger.info(String.format("License found! %s uses %s.", root.getName(), license)); + + for (String license : Licenses.names()) { + if (content.contains(license)) { + logger.info(String.format("License found! %s uses %s.", + root.getName(), license)); return new License(license); } }