Commit 71d0c4ae authored by Roxane Kang Maréchal's avatar Roxane Kang Maréchal
Browse files

Removed unessacery conditions and iterate

parent baef321b
: Pre-requisites :
: * the FART tool : https://sourceforge.net/projects/fart-it/
: * A correct analysis.launch file to serve as base
: This scripts generates for each input xmi, a corresponding launch file which makes checking results faster and easier
@echo off
setlocal enabledelayedexpansion
:: for /f "tokens=* delims=" %%# in ('call xpath analysis.launch "*//mapAttribute[key='IN']/@value"') do set "currentinput=%%#"
: Checks parameter for current IN model name in analysis.launch
if "%~1"=="" (
echo "Enter the name of current IN model in file analysis.launch (for e.g : ./gen-launch-config.bat comment-required)"
exit 0
......@@ -11,8 +17,7 @@ if "%~1"=="" (
echo "Current input : %%currentinput"
)
: For each input file, generate the corresponding .launch file with this file's name as IN model
for %%f in (input\*.xmi) do (
set /p content=<%%f
echo "fullname: %%f"
......
......@@ -589,7 +589,7 @@ rule MeasureCommentRequired(element: java!BodyDeclaration, violatedProperties: S
shortDescription <- 'Denotes whether comments are required (or unwanted) for specific language elements.'
),
measurement: smm!DirectMeasurement (
error <- 'Violated the properties {' + violatedProperties + '} in Class: ' + element.originalCompilationUnit.name + ' -> ' + element.oclType().name + ': ' + element.modifier.visibility + ' ' + thisModule.getBodyDeclarationName(element)
error <- 'Violated the properties ' + violatedProperties + ' in Class: ' + element.originalCompilationUnit.name + ' -> ' + element.oclType().name + ': ' + element.modifier.visibility + ' ' + thisModule.getBodyDeclarationName(element)
)
do {
commentRequired;
......
......@@ -33,13 +33,11 @@ helper def: violatesCommentRequired(elem: java!BodyDeclaration): Boolean =
helper def: violatedCommentRequiredProperties(elem: java!BodyDeclaration): String =
-- Get the set of property tuples associated to elem by using elem data type as key to the Map
thisModule.commentRequiredPropertyDefinitions().get(elem.oclType().name)
let propertyNames:String = '' in thisModule.commentRequiredPropertyDefinitions().get(elem.oclType().name)
-- Concatenate to propertyNames : the name of each property rules that matches requirements for elem
->select(propertyTuple | thisModule.matchesCommentRequiredProperty('Required',elem, propertyTuple))
->iterate (tuple; propertyNames: String = '' |
propertyNames.concat(tuple.property+';')
)
->collect(tuple | propertyNames.concat(tuple.property))
;
-- Returns true if the given property tuple applies to the given elem, false otherwise
......@@ -68,28 +66,14 @@ helper def: matchesCommentRequiredProperty(
.and(
tuple.prefixes.isEmpty() or
tuple.prefixes->exists(p |
-- If elem is of type FieldDeclaration, name field is null so we have to use fragments
if (elem.oclIsTypeOf(java!FieldDeclaration))
then elem.fragments.first().name.startsWith(p)
else elem.name.startsWith(p)
endif
-- This creates problem : Operation not found: OclUndefined.startsWith(java.lang.String)
-- (elem.oclIsTypeOf(java!FieldDeclaration) and (elem.fragments.first().name.startsWith(p)))
-- or elem.name.startsWith(p)
)
)
--if (tuple.prefixes.isEmpty()) then true
--else
-- if (tuple.prefixes->exists(p |
-- If elem is of type FieldDeclaration, name field is null so we have to use fragments
-- if (elem.oclIsTypeOf(java!FieldDeclaration))
-- then elem.fragments.first().name.startsWith(p)
-- else elem.name.startsWith(p)
-- endif)
-- ) then true else false endif
--endif)
;
-- Returns true if the elem has comments, false otherwise
......
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