Commit 492ecd90 authored by Yannis LE BARS's avatar Yannis LE BARS
Browse files

Resolve Conflitcs

parents dc840f87 27873e4f
<?xml version="1.0" encoding="ASCII"?>
<java:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://www.eclipse.org/MoDisco/Java/0.2.incubation/java" name="dontCallThreadRun">
<ownedElements name="dontCallThreadRun">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="Main">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="main">
<modifier visibility="public" static="true"/>
<body originalCompilationUnit="//@compilationUnits.0">
<statements xsi:type="java:VariableDeclarationStatement" originalCompilationUnit="//@compilationUnits.0">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="t" usageInVariableAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression/@expression">
<initializer xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@bodyDeclarations.0">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
</initializer>
</fragments>
<modifier/>
</statements>
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// use t.start() instead"/>
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@bodyDeclarations.1">
<expression xsi:type="java:SingleVariableAccess" variable="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0"/>
</expression>
</statements>
<statements xsi:type="java:ExpressionStatement" originalCompilationUnit="//@compilationUnits.0">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.0" content="// same violation"/>
<expression xsi:type="java:MethodInvocation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@bodyDeclarations.1">
<expression xsi:type="java:ClassInstanceCreation" originalCompilationUnit="//@compilationUnits.0" method="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@bodyDeclarations.0">
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.3"/>
</expression>
</expression>
</statements>
</body>
<parameters originalCompilationUnit="//@compilationUnits.0" name="args">
<modifier/>
<type type="//@orphanTypes.9"/>
</parameters>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@orphanTypes.9/@elementType">
<superInterfaces type="//@ownedElements.1/@ownedPackages.1/@ownedElements.0"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.1"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.2"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Comparable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.1">
<typeParameters name="T" proxy="true"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="CharSequence" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.2"/>
<ownedElements xsi:type="java:ClassDeclaration" name="Thread" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0/@initializer/@type //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.2/@expression/@expression/@type">
<bodyDeclarations xsi:type="java:ConstructorDeclaration" name="Thread" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.0/@fragments.0/@initializer //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.2/@expression/@expression"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" name="run" proxy="true" usages="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@expression //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.2/@expression"/>
<superInterfaces type="//@ownedElements.1/@ownedPackages.0/@ownedElements.4"/>
</ownedElements>
<ownedElements xsi:type="java:InterfaceDeclaration" name="Runnable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.3/@superInterfaces.0"/>
</ownedPackages>
<ownedPackages name="io" proxy="true">
<ownedElements xsi:type="java:InterfaceDeclaration" name="Serializable" proxy="true" usagesInTypeAccess="//@ownedElements.1/@ownedPackages.0/@ownedElements.0/@superInterfaces.0"/>
</ownedPackages>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int"/>
<orphanTypes xsi:type="java:PrimitiveTypeLong" name="long"/>
<orphanTypes xsi:type="java:PrimitiveTypeFloat" name="float"/>
<orphanTypes xsi:type="java:PrimitiveTypeDouble" name="double"/>
<orphanTypes xsi:type="java:PrimitiveTypeBoolean" name="boolean"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<orphanTypes xsi:type="java:ArrayType" name="java.lang.String[]" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@parameters.0/@type" dimensions="1">
<elementType type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
</orphanTypes>
<compilationUnits name="Main.java" originalFilePath="/home/raphael/eclipse/workspaceGersonPhoton/dontCallThreadRun/src/dontCallThreadRun/Main.java" commentList="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.1/@comments.0 //@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@body/@statements.2/@comments.0" package="//@ownedElements.0" types="//@ownedElements.0/@ownedElements.0"/>
</java:Model>
<?xml version="1.0" encoding="ASCII"?>
<java:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://www.eclipse.org/MoDisco/Java/0.2.incubation/java" name="ShortMethodName">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="ShortMethodName">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.0" name="a">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.0"/>
<parameters originalCompilationUnit="//@compilationUnits.0" name="i">
<modifier/>
<type type="//@orphanTypes.0"/>
</parameters>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.1" name="TwoShortMethodName">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.1" name="a">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.1">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.1" content="// Violation" enclosedByParent="true"/>
</body>
<parameters originalCompilationUnit="//@compilationUnits.1" name="i">
<modifier/>
<type type="//@orphanTypes.0"/>
</parameters>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.1" name="b">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.1">
<comments xsi:type="java:LineComment" originalCompilationUnit="//@compilationUnits.1" content="// Violation" enclosedByParent="true"/>
</body>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.2" name="NoShortMethodName">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:MethodDeclaration" originalCompilationUnit="//@compilationUnits.2" name="nottooshort">
<modifier visibility="public"/>
<body originalCompilationUnit="//@compilationUnits.2"/>
<parameters originalCompilationUnit="//@compilationUnits.2" name="i">
<modifier/>
<type type="//@orphanTypes.0"/>
</parameters>
<returnType type="//@orphanTypes.5"/>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<orphanTypes xsi:type="java:PrimitiveTypeInt" name="int" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@parameters.0/@type //@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@parameters.0/@type //@ownedElements.0/@ownedElements.2/@bodyDeclarations.0/@parameters.0/@type"/>
<orphanTypes xsi:type="java:PrimitiveTypeLong" name="long"/>
<orphanTypes xsi:type="java:PrimitiveTypeFloat" name="float"/>
<orphanTypes xsi:type="java:PrimitiveTypeDouble" name="double"/>
<orphanTypes xsi:type="java:PrimitiveTypeBoolean" name="boolean"/>
<orphanTypes xsi:type="java:PrimitiveTypeVoid" name="void" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@returnType //@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@returnType //@ownedElements.0/@ownedElements.1/@bodyDeclarations.1/@returnType //@ownedElements.0/@ownedElements.2/@bodyDeclarations.0/@returnType"/>
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="ShortMethodName.java" originalFilePath="/comptes/E135794C/workspaces/Modeling-photon/ShortMethodName/src/ShortMethodName.java" types="//@ownedElements.0/@ownedElements.0"/>
<compilationUnits name="TwoShortMethodName.java" originalFilePath="/comptes/E135794C/workspaces/Modeling-photon/ShortMethodName/src/TwoShortMethodName.java" commentList="//@ownedElements.0/@ownedElements.1/@bodyDeclarations.0/@body/@comments.0 //@ownedElements.0/@ownedElements.1/@bodyDeclarations.1/@body/@comments.0" types="//@ownedElements.0/@ownedElements.1"/>
<compilationUnits name="NoShortMethodName.java" originalFilePath="/comptes/E135794C/workspaces/Modeling-photon/ShortMethodName/src/NoShortMethodName.java" types="//@ownedElements.0/@ownedElements.2"/>
</java:Model>
......@@ -22,7 +22,9 @@ rule Java2SMM {
helper def: allMeasures(project : java!Model): Set(smm!Measure) =
Set{
thisModule.dontCallThreadRun(), --to test, use input/dont-call-thread-run.xmi
thisModule.numberOfClasses(),
thisModule.shortMethodName(), to test, use input/example_ShortMethodName.xmi
thisModule.tooManyFields(), -- to test, use input/example_toomanyfields.xmi
thisModule.tooFewBranchesForASwitchStatement(),
thisModule.useIndexOfChar(), --to test, use input/useIndexOfChar_java.xmi
......@@ -33,7 +35,6 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
--
};
-- Rule for metrics AvoidDollarSigns : return the set of class Measures that violates the rule.
helper def: AvoidDollarSigns() : Set(smm!Measure) =
-- Browse through all variable/method/class/interface.
......@@ -60,12 +61,41 @@ rule MesureAvoidDollarSigns(node : java!ASTNode) {
measurement: smm!DirectMeasurement (
error <- node.name + ' has dollar in ' + node.originalCompilationUnit.name
)
do {
noc;
}
}
-- Rule for metrics shortMethodName : return the set of method Measures that violates the rule.
helper def: shortMethodName() : Set(smm!Measure) =
-- Browse through all method
java!MethodDeclaration.allInstances() -> reject(each | each.isProxy())->iterate(i; res : Set(smm!Measure) = Set{} |
-- Add a new measurement if the size of the method name is less than 3.
if i.name.size() < 3
then res->union(Set{thisModule.MesureShortMethodName(i)})
else res
endif
);
-- A Measure instance if the class violates the rule 'ShortMethodName'.
rule MesureShortMethodName(method : java!MethodDeclaration) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'ShortMethodName',
shortDescription <- 'Method names names that are very short are not helpful to the reader.'
),
measurement: smm!DirectMeasurement (
error <- method.name + ' is too short in ' + method.originalCompilationUnit.name
)
do {
noc;
}
}
--Goes through all the methods to check if the following rule is followed:
--Don't call Thread.run()
helper def: dontCallThreadRun() : Set(smm!Measure) =
......@@ -123,6 +153,7 @@ rule MeasureDontCallThreadRun(method : java!MethodInvocation) {
}
-- Rule for metrics TooManyFields : return the set of class Measures that violates the rule.
-- To test, example_toomanyfields.xmi, two classe must violates the rule.
helper def: tooManyFields() : Set(smm!Measure) =
-- Browse through all class
java!ClassDeclaration.allInstances() -> reject(each | each.isProxy())->iterate(i; res : Set(smm!Measure) = Set{} |
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment