Commit 06428213 authored by Gerson SUNYE's avatar Gerson SUNYE
Browse files

Merge branch 'fix/770-CommentRequired' into 'master'

Fix bugged rule #770 CommentRequired

See merge request naomod/mde/projet-2019!155
parents 2f4ad8d5 bfd1d37b
<?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="Test">
<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="EnumAsIdentifier">
<ownedElements name="(default package)">
<ownedElements xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="A">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:ClassDeclaration" originalCompilationUnit="//@compilationUnits.0" name="Foo">
<modifier visibility="public"/>
<bodyDeclarations xsi:type="java:FieldDeclaration">
<type/>
<bodyDeclarations xsi:type="java:FieldDeclaration" originalCompilationUnit="//@compilationUnits.0">
<modifier/>
<type type="//@ownedElements.1/@ownedPackages.0/@ownedElements.0"/>
<fragments originalCompilationUnit="//@compilationUnits.0" name="enum">
<initializer xsi:type="java:StringLiteral" originalCompilationUnit="//@compilationUnits.0" escapedValue="&quot;foo&quot;"/>
</fragments>
</bodyDeclarations>
</bodyDeclarations>
</ownedElements>
</ownedElements>
<ownedElements name="java" proxy="true">
<ownedPackages name="lang" proxy="true">
<ownedElements xsi:type="java:ClassDeclaration" name="String" proxy="true" usagesInTypeAccess="//@ownedElements.0/@ownedElements.0/@bodyDeclarations.0/@bodyDeclarations.0/@type">
<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"/>
</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"/>
......@@ -20,5 +40,5 @@
<orphanTypes xsi:type="java:PrimitiveTypeChar" name="char"/>
<orphanTypes xsi:type="java:PrimitiveTypeShort" name="short"/>
<orphanTypes xsi:type="java:PrimitiveTypeByte" name="byte"/>
<compilationUnits name="A.java" originalFilePath="D:\workSpace\Test\src\A.java" types="//@ownedElements.0/@ownedElements.0"/>
<compilationUnits name="A.java" originalFilePath="G:\Gitlab\m2-mde-projet\src\main\java\EnumAvoidAsIdentifier\src\A.java" types="//@ownedElements.0/@ownedElements.0"/>
</java:Model>
......@@ -96,6 +96,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
-- Documentation rules
--
thisModule.commentContent(),
thisModule.commentRequired(),
-- Error prone rules
--
......@@ -136,7 +137,6 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
-- Bugged rules:
--
-- thisModule.UseArrayListInsteadOfVector(),
-- thisModule.commentRequired(),
-- thisModule.compareObjectsWithEquals(),
-- thisModule.emptyFinallyBlock(),
-- thisModule.emptyfinalizeMethod(),
......@@ -154,6 +154,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
};
-- creates a new Measure when String.valueOf is called to append its argument to a string
rule MeasureUselessStringValueOf(method : java!MethodInvocation) {
to
......@@ -746,18 +747,6 @@ helper context java!BodyDeclaration def: getBodyDeclarationName() : String =
helper context java!FieldDeclaration def: getBodyDeclarationName() : String =
self.fragments.first().name;
--- Returns the AnnotationTypeDeclaration corresponding to the given BodyDeclaration
-- This is necessary because BodyDeclaration.annotations returns Sequence(!IN<unamed>)
helper def: getAnnotationTypeDeclarationsFromBodyDeclaration(elem: java!BodyDeclaration): Set(java!AnnotationTypeDeclaration) =
java!AnnotationTypeDeclaration.allInstances()
->select(annotTypeDec |
annotTypeDec.usagesInTypeAccess->exists(usage |
(usage.eContainer().eContainer().name = elem.name)
.and(usage.eContainer().eContainer().modifier.visibility = elem.modifier.visibility)
.and(usage.eContainer().eContainer().originalCompilationUnit.name = elem.originalCompilationUnit.name))
)
;
-- A Measure instance if the class violates the rule 'SuspiciousEqualsMethodName'
rule MeasureSuspiciousEqualsMethodName(method : java!MethodDeclaration) {
to
......
......@@ -59,8 +59,8 @@ helper def: matchesCommentRequiredProperty(
-- Check correspondance with annotation
.and(
tuple.annotation.isEmpty() or
thisModule.getAnnotationTypeDeclarationsFromBodyDeclaration(elem)
->exists(annotation | annotation.name = tuple.annotation))
elem.annotations
->exists(annotation | annotation.type.type.name = tuple.annotation))
-- Check correspondance with prefixes
.and(
......
Markdown is supported
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