Skip to content
Snippets Groups Projects
Commit 310afe9b authored by Manlio Bacco's avatar Manlio Bacco
Browse files

No commit message

No commit message
parent 5cf1d94f
No related branches found
No related tags found
No related merge requests found
Showing
with 409 additions and 19 deletions
package org.universaal.tools.conformanceTools.checks.api;
import org.eclipse.core.resources.IResource;
public interface Check {
public final String ok = ""; //image path
public final String ko = ""; //image path
public final String maybe = ""; //image path
public String getCheckName();
public String getCheckDescription();
public String check(IResource resource) throws Exception;
public String getCheckResultDescription();
}
\ No newline at end of file
package org.universaal.tools.conformanceTools.checks.impl;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.eclipse.core.resources.IResource;
import org.universaal.tools.conformanceTools.checks.api.Check;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class Activator implements Check {
private String result = "Test not yet performed.";
@Override
public String getCheckName() {
return "Is an Activator class present?";
}
@Override
public String getCheckDescription() {
return "This test will verify if selected project has an associated Activator class.";
}
@Override
public String check(IResource resource) throws Exception {
POM_file test = new POM_file();
File pomFile = test.getPOMfile(resource);
if(pomFile != null){
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document results = docBuilder.parse(pomFile);
NodeList pcks = results.getElementsByTagName("Bundle-Activator");
for(int i = 0; i < pcks.getLength(); i++){
Node pck = pcks.item(i);
if(pck.getNodeType() == Node.ELEMENT_NODE){
Element pck_ = (Element) pck;
if(pck_.getFirstChild() != null && pck_.getFirstChild().getNodeValue() != null && !pck_.getFirstChild().getNodeValue().isEmpty()){
result = "This project has a proper Activator class.";
return ok;
}
}
}
}
result = "This project has not a proper Activator class.";
return ko;
}
@Override
public String getCheckResultDescription() {
return result;
}
}
package org.universaal.tools.conformanceTools.checks.impl;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.m2e.core.internal.IMavenConstants;
import org.universaal.tools.conformanceTools.checks.api.Check;
public class Maven_nature implements Check {
private String result = "Test not yet performed.";
@Override
public String getCheckName() {
return "Is it a Maven project?";
}
@Override
public String getCheckDescription() {
return "This test will verify if selected project is a Maven project";
}
@Override
public String check(IResource resource) throws Exception {
if(SubInterfaces.isProject(resource)){
IProject p = (IProject) resource;
if(p.hasNature(IMavenConstants.NATURE_ID)){
result = "Selected project has Maven nature.";
return ok;
}
}
result = "Selected project has not Maven nature.";
return ko;
}
@Override
public String getCheckResultDescription() {
return result;
}
}
\ No newline at end of file
package org.universaal.tools.conformanceTools.checks.impl;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.m2e.core.internal.IMavenConstants;
import org.universaal.tools.conformanceTools.checks.api.Check;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class NameGroupID implements Check {
private String result = "Test not yet performed.";
private final String AALapp = "org.universAAL.AALaaplication";
private final String AAL = "org.universAAL";
private final String noAAL = "";
@Override
public String getCheckName() {
return "Is the naming convention respected?";
}
@Override
public String getCheckDescription() {
return "This test will verify if name and group ID for the selected project complies to uAAL guidelines.";
}
@Override
public String check(IResource resource) throws Exception {
if(SubInterfaces.isProject(resource)){
IProject p = (IProject) resource;
if(p.getFile(IMavenConstants.POM_FILE_NAME) != null){
File pom = getPOMfile(resource);
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document results = docBuilder.parse(pom);
// groupId artifactId
NodeList groupId = results.getElementsByTagName("groupId");
NodeList artifactId = results.getElementsByTagName("artifactId");
String groupID = null, artifactID = null;
if(groupId != null && groupId.item(0) != null){
if(groupId.item(0).getNodeType() == Node.ELEMENT_NODE){
Element groupId_ = (Element) groupId.item(0);
groupID = checkNamingConvention(groupId_.getTextContent());
}
}
if(artifactId != null && artifactId.item(0) != null){
if(artifactId.item(0).getNodeType() == Node.ELEMENT_NODE){
Element artifactId_ = (Element) artifactId.item(0);
artifactID = checkNamingConvention(artifactId_.getTextContent());
}
}
if(groupID != null && artifactID != null){
if(groupID.equals(AALapp) && artifactId.equals(AALapp))
result = "Selected project is a uAAL application from WP4?";
if(groupID.equals(AAL) && artifactId.equals(AAL))
result = "Selected project is a uAAL code package?";
if(groupID.equals(noAAL) && artifactId.equals(noAAL))
result = "Are you a developer outside uAAL?";
return maybe;
}
else{
result = "Selected project has not valid descriptors.";
return ko;
}
}
}
result = "Selected project has not a valid POM file.";
return ko;
}
@Override
public String getCheckResultDescription() {
return result;
}
private String checkNamingConvention(String tag){
if(tag != null && !tag.isEmpty()){
if(tag.startsWith("org.universAAL.AALaaplication"))
return AALapp;
if(tag.startsWith("org.universAAL"))
return AAL;
}
return noAAL;
}
private File getPOMfile(IResource resource) throws Exception{
return new File(((IProject)resource).getFile(IMavenConstants.POM_FILE_NAME).getLocationURI());
}
}
package org.universaal.tools.conformanceTools.checks.impl;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.universaal.tools.conformanceTools.checks.api.Check;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class OSGI_bundle implements Check{
private String result = "Test not yet performed.";
@Override
public String getCheckName() {
return "Is it an OSGI bundle?";
}
@Override
public String getCheckDescription() {
return "This test will inspect POM file searching for bundle information.";
}
@Override
public String check(IResource resource) throws Exception {
POM_file hasPom = new POM_file();
File pomFile = hasPom.getPOMfile(resource);
if(pomFile != null){
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document results = docBuilder.parse(pomFile);
NodeList pcks = results.getElementsByTagName("packaging");
for(int i = 0; i < pcks.getLength(); i++){
Node pck = pcks.item(i);
if(pck.getNodeType() == Node.ELEMENT_NODE){
Element pck_ = (Element) pck;
if(pck_.getFirstChild() != null && pck_.getFirstChild().getNodeValue().equalsIgnoreCase("bundle")){
result = "This project is an OSGI bundle.";
return ok;
}
}
}
}
result = "This project is not an OSGI bundle.";
return ko;
}
@Override
public String getCheckResultDescription() {
return result;
}
private String getProjectPath(IResource resource) throws CoreException{
return ResourcesPlugin.getWorkspace().getRoot().getLocation().makeAbsolute()+"/"+((IProject)resource).getDescription().getName();
}
}
\ No newline at end of file
package org.universaal.tools.conformanceTools.checks.impl;
import java.io.File;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.m2e.core.internal.IMavenConstants;
import org.universaal.tools.conformanceTools.checks.api.Check;
public class POM_file implements Check {
private String result = "Test not yet performed.";
@Override
public String getCheckName() {
return "Is a POM file present?";
}
@Override
public String getCheckDescription() {
return "This test will verify if selected project has an associated POM file.";
}
@Override
public String check(IResource resource) throws Exception {
if(SubInterfaces.isProject(resource)){
IProject p = (IProject) resource;
if(p.getFile(IMavenConstants.POM_FILE_NAME) != null){
result = "Selected project has POM file.";
return ok;
}
}
result = "Selected project has not a POM file";
return ko;
}
@Override
public String getCheckResultDescription() {
return result;
}
public File getPOMfile(IResource resource) throws Exception{
if(check(resource).equals(ok)){
return new File(((IProject)resource).getFile(IMavenConstants.POM_FILE_NAME).getLocationURI());
}
return null;
}
}
\ No newline at end of file
package org.universaal.tools.conformanceTools.checks.impl;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
public class SubInterfaces {
public static boolean isContainer(IResource resource){
return resource instanceof IContainer;
}
public static boolean isFile(IResource resource){
return resource instanceof IFile;
}
public static boolean isFolder(IResource resource){
return resource instanceof IFolder;
}
public static boolean isProject(IResource resource){
return resource instanceof IProject;
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator2;
import org.universaal.tools.conformanceTools.utils.RunPlugin;
public class BugResolution implements IMarkerResolutionGenerator2 {
......@@ -44,7 +45,13 @@ public class BugResolution implements IMarkerResolutionGenerator2 {
@Override
public void run(IMarker marker) {
try {
markers.deleteMarker(marker);
String plugin = (String) marker.getAttribute(IMarker.SOURCE_ID);
if(plugin.equals(RunPlugin.FindBugs)){
//@edu.umd.cs.findbugs.annotations.SuppressWarnings("URF_UNREAD_FIELD")
String error = (String) marker.getAttribute(IMarker.TEXT);
}
else
markers.deleteMarker(marker);
} catch (CoreException e) {
e.printStackTrace();
}
......
......@@ -50,6 +50,7 @@ import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
import org.osgi.framework.Bundle;
import org.universaal.tools.conformanceTools.Activator;
import org.universaal.tools.conformanceTools.checks.impl.NameGroupID;
import org.universaal.tools.conformanceTools.markers.CTMarker;
import org.universaal.tools.conformanceTools.markers.Markers;
import org.universaal.tools.conformanceTools.utils.HtmlPage;
......@@ -118,13 +119,16 @@ public class ToolsRun {
this.projectToAnalyze = ((IProject) selected);
else {
MessageDialog.openInformation(window.getShell(),
"uAAL Conformance Tools", "Not a project.");
"uAAL Conformance Tools", "the selection is not a project or is broken.");
return;
}
try{
removeOldBugs();
testConformance();
//removeOldBugs();
//testConformance();
NameGroupID t = new NameGroupID();
t.check(this.projectToAnalyze);
}
catch(Exception ex){ ex.printStackTrace(); }
}
......@@ -141,19 +145,19 @@ public class ToolsRun {
try{
// Continuous progress bar
monitor.beginTask("uAAL - verifying conformance", IProgressMonitor.UNKNOWN);
monitor.beginTask("uAAL CT - verifying conformance", IProgressMonitor.UNKNOWN);
IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
if (projectToAnalyze != null && !projectToAnalyze.hasNature(IMavenConstants.NATURE_ID)) {
monitor.done();
return new Status(Status.ERROR, Activator.PLUGIN_ID, "uAAL - not a Maven project.");
return new Status(Status.ERROR, Activator.PLUGIN_ID, "uAAL CT - not a Maven project.");
}
IFile pomResource = projectToAnalyze.getFile(IMavenConstants.POM_FILE_NAME);
if (pomResource == null) {
monitor.done();
return new Status(Status.ERROR, Activator.PLUGIN_ID, "uAAL - missing POM file.");
return new Status(Status.ERROR, Activator.PLUGIN_ID, "uAAL CT - missing POM file.");
}
IMavenProjectFacade projectFacade = projectManager.create(pomResource, true, monitor);
......@@ -186,9 +190,9 @@ public class ToolsRun {
}
monitor.done();
System.out.println("uAAL CT: report blocked - "+errors);
if(errors.contains("java.lang.OutOfMemoryError"))
System.out.println("uAAL CT: verify start parameter [-XX:MaxPermSize] of AAL Studio and increase the value set.");
System.out.println("uAAL CT - report blocked - "+errors);
//if(errors.contains("java.lang.OutOfMemoryError"))
//System.out.println("uAAL CT: verify start parameter [-XX:MaxPermSize] of AAL Studio and increase the value set.");
return new Status(Status.ERROR, Activator.PLUGIN_ID, errors);
}
......@@ -196,7 +200,7 @@ public class ToolsRun {
monitor.done(); // test monitor
// generate report and visualize it
monitor.beginTask("uAAL - reporting conformance tests.", IProgressMonitor.UNKNOWN);
monitor.beginTask("uAAL CT - reporting conformance tests.", IProgressMonitor.UNKNOWN);
goals.clear();
MavenExecutionRequest request2 = projectManager.createExecutionRequest(pomResource,
......@@ -228,7 +232,7 @@ public class ToolsRun {
}
monitor.done();
return new Status(Status.ERROR, Activator.PLUGIN_ID, "uAAL CT: "+errors);
return new Status(Status.ERROR, Activator.PLUGIN_ID, "uAAL CT - "+errors);
}
// visualize report - open report file
......@@ -265,7 +269,7 @@ public class ToolsRun {
if(page != null && fileStore != null)
IDE.openEditorOnFileStore( page, fileStore );
else
System.out.println("uAAL CT: can't open report file - "+plugin);
System.out.println("uAAL CT - can't open report file - "+plugin);
}
catch ( PartInitException e ) {
e.printStackTrace();
......@@ -273,7 +277,7 @@ public class ToolsRun {
}
else
System.out.println("uAAL CT: does file "+path_+"/target/site/"+"fileNameResults"+" exist?");
System.out.println("uAAL CT - does file "+path_+"/target/site/"+"fileNameResults"+" exist?");
}
catch(Exception ex){
......@@ -293,7 +297,7 @@ public class ToolsRun {
}
monitor.done();
return new Status(Status.OK, Activator.PLUGIN_ID, "uAAL CT - all ok!");
return new Status(Status.OK, Activator.PLUGIN_ID, "uAAL CT - good!");
}
};
......@@ -483,7 +487,8 @@ public class ToolsRun {
attributes.put(IMarker.LINE_NUMBER, orderderbugsMap.get(j).getLine());
attributes.put(IMarker.MESSAGE, orderderbugsMap.get(j).getDescr());
attributes.put(IMarker.LOCATION, orderderbugsMap.get(j).getFrontEndID());
attributes.put(IMarker.LINE_NUMBER, orderderbugsMap.get(j).getLine());
attributes.put(IMarker.LINE_NUMBER, orderderbugsMap.get(j).getLine());
attributes.put(IMarker.TEXT, orderderbugsMap.get(j).getErrorType());
if(!orderderbugsMap.get(j).getSeverityDescription().equals(no_severity)){
......
......@@ -28,7 +28,7 @@ public class MainFrame {
GridData data = new GridData(GridData.FILL_BOTH);
Button two = new Button(shell, SWT.PUSH);
two.setText("CheckStyle plugin");
two.setText("Check against code style rules");
two.setEnabled(true);
two.addMouseListener(new MouseListener() {
......@@ -48,7 +48,7 @@ public class MainFrame {
two.setLayoutData(data);
Button four = new Button(shell, SWT.PUSH);
four.setText("FindBugs plugin");
four.setText("Identify the most common bugs");
four.setEnabled(true);
four.addMouseListener(new MouseListener() {
......@@ -68,7 +68,7 @@ public class MainFrame {
four.setLayoutData(data);
Button five = new Button(shell, SWT.PUSH);
five.setText("Maven Verifier plugin");
five.setText("Verify files in project");
five.setEnabled(false);
five.addMouseListener(new MouseListener() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment