Slint: fix bugs and add CSV output for CNES 03/17503/2
Calixte DENIZET [Fri, 27 Nov 2015 12:38:24 +0000 (13:38 +0100)]
Change-Id: Iedbf4edaf6e99f2f5da569b1695f1af6fa85913b

26 files changed:
scilab/modules/slint/Makefile.am
scilab/modules/slint/Makefile.in
scilab/modules/slint/etc/cnes_analysis_conf.xml
scilab/modules/slint/etc/cnes_tool_conf.xml
scilab/modules/slint/etc/slint.xml
scilab/modules/slint/includes/FileException.hxx
scilab/modules/slint/includes/checkers/SLintChecker.hxx
scilab/modules/slint/includes/checkers/VariablesChecker.hxx
scilab/modules/slint/includes/output/SLintResult.hxx
scilab/modules/slint/includes/output/SLintScilabResult.hxx
scilab/modules/slint/includes/output/SLintXmlResult.hxx
scilab/modules/slint/includes/output/cnes/CNESCsvResult.hxx [new file with mode: 0644]
scilab/modules/slint/includes/output/cnes/CNESXmlResult.hxx [moved from scilab/modules/slint/includes/output/cnes/CNESResult.hxx with 68% similarity]
scilab/modules/slint/sci_gateway/cpp/sci_slint.cpp
scilab/modules/slint/slint.vcxproj
scilab/modules/slint/slint.vcxproj.filters
scilab/modules/slint/src/cpp/CNESConfig.cpp
scilab/modules/slint/src/cpp/CNESCsvResult.cpp [new file with mode: 0644]
scilab/modules/slint/src/cpp/CNESXmlResult.cpp [moved from scilab/modules/slint/src/cpp/CNESResult.cpp with 76% similarity]
scilab/modules/slint/src/cpp/FileException.cpp
scilab/modules/slint/src/cpp/NestedBlocksChecker.cpp
scilab/modules/slint/src/cpp/SLint.cpp
scilab/modules/slint/src/cpp/SLintChecker.cpp
scilab/modules/slint/src/cpp/SLintScilabResult.cpp
scilab/modules/slint/src/cpp/SLintXmlResult.cpp
scilab/modules/slint/src/cpp/VariablesChecker.cpp

index 512453b..214f610 100644 (file)
@@ -97,7 +97,8 @@ src/cpp/ToolConfiguration.cpp \
 src/cpp/ToolConfigurationType.cpp \
 src/cpp/CNESException.cpp \
 src/cpp/CNESConfig.cpp \
-src/cpp/CNESResult.cpp
+src/cpp/CNESXmlResult.cpp \
+src/cpp/CNESCsvResult.cpp
 
 GATEWAY_CXX_SOURCES = \
     sci_gateway/cpp/sci_slint.cpp
index ba22eea..5a26cc1 100644 (file)
@@ -237,7 +237,8 @@ am__objects_1 = src/cpp/libscislint_algo_la-SLintContext.lo \
        src/cpp/libscislint_algo_la-ToolConfigurationType.lo \
        src/cpp/libscislint_algo_la-CNESException.lo \
        src/cpp/libscislint_algo_la-CNESConfig.lo \
-       src/cpp/libscislint_algo_la-CNESResult.lo
+       src/cpp/libscislint_algo_la-CNESXmlResult.lo \
+       src/cpp/libscislint_algo_la-CNESCsvResult.lo
 am_libscislint_algo_la_OBJECTS = $(am__objects_1)
 libscislint_algo_la_OBJECTS = $(am_libscislint_algo_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -767,7 +768,8 @@ src/cpp/ToolConfiguration.cpp \
 src/cpp/ToolConfigurationType.cpp \
 src/cpp/CNESException.cpp \
 src/cpp/CNESConfig.cpp \
-src/cpp/CNESResult.cpp
+src/cpp/CNESXmlResult.cpp \
+src/cpp/CNESCsvResult.cpp
 
 GATEWAY_CXX_SOURCES = \
     sci_gateway/cpp/sci_slint.cpp
@@ -1042,7 +1044,9 @@ src/cpp/libscislint_algo_la-CNESException.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libscislint_algo_la-CNESConfig.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
-src/cpp/libscislint_algo_la-CNESResult.lo: src/cpp/$(am__dirstamp) \
+src/cpp/libscislint_algo_la-CNESXmlResult.lo: src/cpp/$(am__dirstamp) \
+       src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libscislint_algo_la-CNESCsvResult.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
 
 libscislint-algo.la: $(libscislint_algo_la_OBJECTS) $(libscislint_algo_la_DEPENDENCIES) $(EXTRA_libscislint_algo_la_DEPENDENCIES) 
@@ -1078,8 +1082,9 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscislint_algo_la-BracketedExpChecker.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscislint_algo_la-BreaksInLoopChecker.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscislint_algo_la-CNESConfig.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscislint_algo_la-CNESCsvResult.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscislint_algo_la-CNESException.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscislint_algo_la-CNESResult.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscislint_algo_la-CNESXmlResult.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscislint_algo_la-CommentRatioChecker.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscislint_algo_la-DecimalChecker.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscislint_algo_la-DeprecatedChecker.Plo@am__quote@
@@ -1665,12 +1670,19 @@ src/cpp/libscislint_algo_la-CNESConfig.lo: src/cpp/CNESConfig.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscislint_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscislint_algo_la-CNESConfig.lo `test -f 'src/cpp/CNESConfig.cpp' || echo '$(srcdir)/'`src/cpp/CNESConfig.cpp
 
-src/cpp/libscislint_algo_la-CNESResult.lo: src/cpp/CNESResult.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscislint_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscislint_algo_la-CNESResult.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscislint_algo_la-CNESResult.Tpo -c -o src/cpp/libscislint_algo_la-CNESResult.lo `test -f 'src/cpp/CNESResult.cpp' || echo '$(srcdir)/'`src/cpp/CNESResult.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscislint_algo_la-CNESResult.Tpo src/cpp/$(DEPDIR)/libscislint_algo_la-CNESResult.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/CNESResult.cpp' object='src/cpp/libscislint_algo_la-CNESResult.lo' libtool=yes @AMDEPBACKSLASH@
+src/cpp/libscislint_algo_la-CNESXmlResult.lo: src/cpp/CNESXmlResult.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscislint_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscislint_algo_la-CNESXmlResult.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscislint_algo_la-CNESXmlResult.Tpo -c -o src/cpp/libscislint_algo_la-CNESXmlResult.lo `test -f 'src/cpp/CNESXmlResult.cpp' || echo '$(srcdir)/'`src/cpp/CNESXmlResult.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscislint_algo_la-CNESXmlResult.Tpo src/cpp/$(DEPDIR)/libscislint_algo_la-CNESXmlResult.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/CNESXmlResult.cpp' object='src/cpp/libscislint_algo_la-CNESXmlResult.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscislint_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscislint_algo_la-CNESXmlResult.lo `test -f 'src/cpp/CNESXmlResult.cpp' || echo '$(srcdir)/'`src/cpp/CNESXmlResult.cpp
+
+src/cpp/libscislint_algo_la-CNESCsvResult.lo: src/cpp/CNESCsvResult.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscislint_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscislint_algo_la-CNESCsvResult.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscislint_algo_la-CNESCsvResult.Tpo -c -o src/cpp/libscislint_algo_la-CNESCsvResult.lo `test -f 'src/cpp/CNESCsvResult.cpp' || echo '$(srcdir)/'`src/cpp/CNESCsvResult.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscislint_algo_la-CNESCsvResult.Tpo src/cpp/$(DEPDIR)/libscislint_algo_la-CNESCsvResult.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/CNESCsvResult.cpp' object='src/cpp/libscislint_algo_la-CNESCsvResult.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscislint_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscislint_algo_la-CNESResult.lo `test -f 'src/cpp/CNESResult.cpp' || echo '$(srcdir)/'`src/cpp/CNESResult.cpp
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscislint_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscislint_algo_la-CNESCsvResult.lo `test -f 'src/cpp/CNESCsvResult.cpp' || echo '$(srcdir)/'`src/cpp/CNESCsvResult.cpp
 
 sci_gateway/cpp/libscislint_la-sci_slint.lo: sci_gateway/cpp/sci_slint.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscislint_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscislint_la-sci_slint.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscislint_la-sci_slint.Tpo -c -o sci_gateway/cpp/libscislint_la-sci_slint.lo `test -f 'sci_gateway/cpp/sci_slint.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_slint.cpp
index 255eb22..200986a 100644 (file)
@@ -3,19 +3,19 @@
     <analysisRule analysisRuleId="GlobalKeyword" analysisRuleActivation="true" />
     <analysisRule analysisRuleId="Redefinition" analysisRuleActivation="true" />
     <analysisRule analysisRuleId="Variables" analysisRuleActivation="true" />
-    <analysisRule analysisRuleId="FunctionName" analysisRuleActivation="true">
+    <analysisRule analysisRuleId="FunctionName" analysisRuleActivation="false">
         <analysisRuleParameter analysisRuleParameterName="pattern" analysisRuleTextValue="[a-z]*" />
         <analysisRuleParameter analysisRuleParameterName="length" analysisRuleValueMin="-1" analysisRuleValueMax="-1" />
     </analysisRule>
-    <analysisRule analysisRuleId="FunctionArgs" analysisRuleActivation="true" />
+    <analysisRule analysisRuleId="FunctionArgs" analysisRuleActivation="false" />
     <analysisRule analysisRuleId="UselessArg" analysisRuleActivation="true" />
     <analysisRule analysisRuleId="UselessRet" analysisRuleActivation="true" />
-    <analysisRule analysisRuleId="VariableName" analysisRuleActivation="true">
+    <analysisRule analysisRuleId="VariableName" analysisRuleActivation="false">
         <analysisRuleParameter analysisRuleParameterName="pattern" analysisRuleTextValue="[a-zA-Z0-9]*" />
         <analysisRuleParameter analysisRuleParameterName="length" analysisRuleValueMin="-1" analysisRuleValueMax="-1" />
     </analysisRule>
     <analysisRule analysisRuleId="SingleInstr" analysisRuleActivation="true" />
-    <analysisRule analysisRuleId="EmptyBlock" analysisRuleActivation="true" />
+    <analysisRule analysisRuleId="EmptyBlock" analysisRuleActivation="false" />
     <analysisRule analysisRuleId="MopenMclose" analysisRuleActivation="true" />
     <analysisRule analysisRuleId="McCabe" analysisRuleActivation="true">
         <analysisRuleParameter analysisRuleParameterName="max" analysisRuleNumericalValue="30" />
         <analysisRuleParameter analysisRuleParameterName="character" analysisRuleTextValue="eE" />
         <analysisRuleParameter analysisRuleParameterName="checkDot" analysisRuleNumericalValue="1" />
     </analysisRule>
-    <analysisRule analysisRuleId="Printf" analysisRuleActivation="true" />
+    <analysisRule analysisRuleId="Printf" analysisRuleActivation="false" />
     <analysisRule analysisRuleId="LineLength" analysisRuleActivation="true">
         <analysisRuleParameter analysisRuleParameterName="max" analysisRuleNumericalValue="80" />
     </analysisRule>
     <analysisRule analysisRuleId="LinesCount" analysisRuleActivation="true">
         <analysisRuleParameter analysisRuleParameterName="max" analysisRuleNumericalValue="200" />
     </analysisRule>
-    <analysisRule analysisRuleId="Todo" analysisRuleActivation="true" />
+    <analysisRule analysisRuleId="Todo" analysisRuleActivation="false" />
     <analysisRule analysisRuleId="NaN" analysisRuleActivation="true" />
-    <analysisRule analysisRuleId="EqEq" analysisRuleActivation="true" />
-    <analysisRule analysisRuleId="UselessOp" analysisRuleActivation="true" />
-    <analysisRule analysisRuleId="UnreachableCode" analysisRuleActivation="true" />
+    <analysisRule analysisRuleId="EqEq" analysisRuleActivation="false" />
+    <analysisRule analysisRuleId="UselessOp" analysisRuleActivation="false" />
+    <analysisRule analysisRuleId="UnreachableCode" analysisRuleActivation="false" />
     <analysisRule analysisRuleId="Deprecated" analysisRuleActivation="true" />
     <analysisRule analysisRuleId="Select" analysisRuleActivation="true">
         <analysisRuleParameter analysisRuleParameterName="default" analysisRuleNumericalValue="1" />
         <analysisRuleParameter analysisRuleParameterName="empty" analysisRuleNumericalValue="1" />
         <analysisRuleParameter analysisRuleParameterName="oneCase" analysisRuleNumericalValue="1" />
     </analysisRule>
-    <analysisRule analysisRuleId="ImplicitList" analysisRuleActivation="true" />
-    <analysisRule analysisRuleId="Struct" analysisRuleActivation="true">
-        <analysisRuleParameter analysisRuleParameterName="fieldPattern" analysisRuleTextValue="[a-z]*" />
-        <analysisRuleParameter analysisRuleParameterName="length" analysisRuleValueMin="-1" analysisRuleValueMax="-1" />
-    </analysisRule>
-    <analysisRule analysisRuleId="LoadSave" analysisRuleActivation="true" />
+    <analysisRule analysisRuleId="ImplicitList" analysisRuleActivation="false" />
     <analysisRule analysisRuleId="OldNot" analysisRuleActivation="true" />
     <analysisRule analysisRuleId="SpacesAroundOp" analysisRuleActivation="true" />
     <analysisRule analysisRuleId="SpacesInArgs" analysisRuleActivation="true" />
@@ -59,7 +54,7 @@
     <analysisRule analysisRuleId="NestedBlocks" analysisRuleActivation="true">
         <analysisRuleParameter analysisRuleParameterName="max" analysisRuleNumericalValue="5" />
     </analysisRule>
-    <analysisRule analysisRuleId="StatInCond" analysisRuleActivation="true">
+    <analysisRule analysisRuleId="ExpInCond" analysisRuleActivation="true">
         <analysisRuleParameter analysisRuleParameterName="max" analysisRuleNumericalValue="5" />
     </analysisRule>
     <analysisRule analysisRuleId="Bracketed" analysisRuleActivation="true" />
index 562560e..301c0c8 100644 (file)
@@ -1,44 +1,43 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <toolConfiguration toolConfigurationId="" toolName="slint" toolVersion="0.0">
     <ruleLink standardRuleId="SCI.INST.Global" analysisRuleId="GlobalKeyword" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0002" analysisRuleId="Redefinition" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="COM.DATA.Initialisation" analysisRuleId="Variables" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0004" analysisRuleId="FunctionName" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0005" analysisRuleId="FunctionArgs" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0006" analysisRuleId="UselessArg" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0007" analysisRuleId="UselessRet" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0008" analysisRuleId="VariableName" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="COM.NAME.Homonymy" analysisRuleId="Redefinition" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="COM.DATA.Initialisation" analysisRuleId="Variables.Uninitialized" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="COM.DATA.NotUsed" analysisRuleId="Variables.Unused" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="" analysisRuleId="FunctionName" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="" analysisRuleId="FunctionArgs" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="COM.DATA.NotUsed" analysisRuleId="UselessArg" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="COM.DATA.NotUsed" analysisRuleId="UselessRet" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="" analysisRuleId="VariableName" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="COM.INST.Line" analysisRuleId="SingleInstr" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0010" analysisRuleId="EmptyBlock" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="" analysisRuleId="EmptyBlock" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="SCI.INST.EndLine" analysisRuleId="SemicolonAtEOL" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="SCI.DATA.mclose" analysisRuleId="MopenMclose" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="COM.MET.ComplexitySimplified" analysisRuleId="McCabe" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="SCI.PRES.ScientificNotation" analysisRuleId="Decimal" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0015" analysisRuleId="Printf" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="" analysisRuleId="Printf" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="SCI.PRES.LengthLine" analysisRuleId="LineLength" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="COM.MET.LineOfCode" analysisRuleId="LinesCount" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0018" analysisRuleId="Todo" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="" analysisRuleId="Todo" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="SCI.INST.isNAN" analysisRuleId="NaN" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0020" analysisRuleId="EqEq" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0021" analysisRuleId="UselessOp" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0022" analysisRuleId="UnreachableCode" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="" analysisRuleId="EqEq" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="" analysisRuleId="UselessOp" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="" analysisRuleId="UnreachableCode" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="SCI.INST.Deprecated" analysisRuleId="Deprecated" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="COM.FLOW.CaseSwitch" analysisRuleId="Select" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0025" analysisRuleId="ImplicitList" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0026" analysisRuleId="Struct" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0027" analysisRuleId="LoadSave" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="" analysisRuleId="ImplicitList" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="SCI.INST.At" analysisRuleId="OldNot" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="COM.PRES.Ventilate" analysisRuleId="SpacesAroundOp" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0030" analysisRuleId="SpacesInArgs" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="COM.PRES.Ventilate" analysisRuleId="SpacesInArgs" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="SCI.INST.Break" analysisRuleId="BreaksInLoop" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="COM.MET.Nesting" analysisRuleId="NestedBlocks" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0033" analysisRuleId="StatInCond" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0034" analysisRuleId="BracketedExp" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0035" analysisRuleId="NotNot" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="COM.FLOW.BooleanExpression" analysisRuleId="ExpInCond" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="COM.INST.Brace" analysisRuleId="BracketedExp" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="COM.INST.BoolNegation" analysisRuleId="NotNot" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="SCI.INST.BannedFunction" analysisRuleId="IllegalCalls" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0037" analysisRuleId="CommentRatio" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="COM.MET.RatioComment" analysisRuleId="CommentRatio" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="SCI.FLOW.ArgumentName" analysisRuleId="FunctionArgsOrder" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="COM.FLOW.CheckCodeReturn" analysisRuleId="FunctionTestReturn" ruleCoverage="Complete" standardId=""/>
-    <ruleLink standardRuleId="CNES0040" analysisRuleId="ReturnsCount" ruleCoverage="Complete" standardId=""/>
+    <ruleLink standardRuleId="COM.FLOW.Exit" analysisRuleId="ReturnsCount" ruleCoverage="Complete" standardId=""/>
     <ruleLink standardRuleId="SCI.PRES.Comparison" analysisRuleId="NotEqual" ruleCoverage="Complete" standardId=""/>
 </toolConfiguration>
index 7c07a30..b34c8b6 100644 (file)
@@ -30,8 +30,8 @@
     <SpacesAroundOp enable="true" id="00028"/>
     <SpacesInArgs enable="true" id="00029"/>
     <BreaksInLoop enable="true" maxBreaks="1" maxContinues="1" id="00030"/>
-    <NestedBlocks enable="true" max="5" id="00031"/>
-    <StatInCond enable="true" max="5" id="00032"/>
+    <NestedBlocks enable="true" max="3" id="00031"/>
+    <ExpInCond enable="true" max="5" id="00032"/>
     <BracketedExp enable="true" id="00033"/>
     <NotNot enable="true" id="00034"/>
     <IllegalCalls enable="true" id="00035">
index c0b7f1f..dd8cbf1 100644 (file)
@@ -26,6 +26,7 @@ class FileException : public std::exception
 public:
 
     FileException(const std::wstring & filename, const std::wstring & error);
+    FileException(const std::wstring & filename, const std::string & error);
 
 #ifdef _MSC_VER
     virtual const char * what() const;
index c456f67..83d7742 100644 (file)
@@ -100,6 +100,11 @@ public:
     virtual const std::wstring & getId() const;
 
     /**
+     * Get the checker id for the sub rule
+     */
+    virtual const std::wstring getId(const unsigned sub) const;
+
+    /**
      * Check if the name corresponds to a Scilab's constant
      */
     static bool isScilabConstant(const std::wstring & name);
index 8e28e07..56c1cb1 100644 (file)
@@ -39,6 +39,7 @@ public:
     void preCheckNode(const ast::Exp & e, SLintContext & context, SLintResult & result);
     void postCheckNode(const ast::Exp & e, SLintContext & context, SLintResult & result);
     const std::string getName() const;
+    const std::wstring getId(const unsigned sub) const;
 
     virtual const std::vector<ast::Exp::ExpType> getAstNodes() const
     {
index 277b602..896b45c 100644 (file)
@@ -36,19 +36,33 @@ public:
     template<typename... Args>
     void report(SLintContext & context, const Location & loc, const SLintChecker & checker, const std::wstring & err, Args... args)
     {
-        handleMessage(context, loc, checker, make_string(err, args...));
+        handleMessage(context, loc, checker, 0, make_string(err, args...));
     }
 
     template<typename... Args>
     void report(SLintContext & context, const Location & loc, const SLintChecker & checker, const std::string & err, Args... args)
     {
         wchar_t * _err = to_wide_string(err.c_str());
-        handleMessage(context, loc, checker, make_string(std::wstring(_err), args...));
+        handleMessage(context, loc, checker, 0, make_string(std::wstring(_err), args...));
+        FREE(_err);
+    }
+
+    template<typename... Args>
+    void report(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & err, Args... args)
+    {
+        handleMessage(context, loc, checker, sub, make_string(err, args...));
+    }
+
+    template<typename... Args>
+    void report(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::string & err, Args... args)
+    {
+        wchar_t * _err = to_wide_string(err.c_str());
+        handleMessage(context, loc, checker, sub, make_string(std::wstring(_err), args...));
         FREE(_err);
     }
 
     virtual void handleFiles(const std::vector<SciFilePtr> & files) = 0;
-    virtual void handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const std::wstring & msg) = 0;
+    virtual void handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg) = 0;
 
     virtual void finalize() { }
 
index 0198773..0d6040c 100644 (file)
@@ -39,7 +39,7 @@ public:
     SLintScilabResult();
     virtual ~SLintScilabResult();
     virtual void handleFiles(const std::vector<SciFilePtr> & files) { }
-    virtual void handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const std::wstring & msg);
+    virtual void handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg);
     virtual void finalize();
 };
 
@@ -54,7 +54,7 @@ public:
     SLintScilabOut();
     virtual ~SLintScilabOut();
     virtual void handleFiles(const std::vector<SciFilePtr> & files) { }
-    virtual void handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const std::wstring & msg);
+    virtual void handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg);
     virtual void finalize();
 
     types::Struct * getStruct() const;
index cceec17..37a0a61 100644 (file)
@@ -35,7 +35,7 @@ public:
 
     virtual ~SLintXmlResult();
     virtual void handleFiles(const std::vector<SciFilePtr> & files) { }
-    virtual void handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const std::wstring & msg);
+    virtual void handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg);
     virtual void finalize();
 
     static std::wstring replaceByEntities(const std::wstring & seq);
@@ -44,9 +44,9 @@ public:
 private:
 
     void print(const SciFilePtr & file);
-    void print(const Location & loc, const SLintChecker & checker, const std::wstring & msg);
+    void print(const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg);
     void print(const Location & loc);
-    void print(const SLintChecker & checker);
+    void print(const SLintChecker & checker, const unsigned sub);
     void print(const std::wstring & msg);
 
     inline static void pushEntity(std::vector<wchar_t> & buf, const wchar_t * wstr, const unsigned char len)
diff --git a/scilab/modules/slint/includes/output/cnes/CNESCsvResult.hxx b/scilab/modules/slint/includes/output/cnes/CNESCsvResult.hxx
new file mode 100644 (file)
index 0000000..10d5b03
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2015 - Scilab Enterprises - Calixte DENIZET
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __SLINT_CNES_CSV_RESULT_HXX__
+#define __SLINT_CNES_CSV_RESULT_HXX__
+
+#include <fstream>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "config/cnes/ToolConfiguration.hxx"
+#include "output/SLintResult.hxx"
+
+namespace types
+{
+class String;
+}
+
+namespace slint
+{
+
+class SciFile;
+
+namespace CNES
+{
+
+class CNESCsvResult : public SLintResult
+{
+    const ToolConfigurationType tct;
+    const std::wstring path;
+    std::ofstream * out;
+    SciFilePtr current;
+    std::unordered_map<std::wstring, std::vector<std::pair<Location, std::wstring>>> res;
+
+public:
+
+    CNESCsvResult(const ToolConfiguration & tc, types::String * conf, const std::wstring & id, const std::wstring & _path);
+
+    virtual ~CNESCsvResult();
+    virtual void handleFiles(const std::vector<SciFilePtr> & files);
+    virtual void handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg);
+    virtual void finalize();
+
+private:
+
+    void printRes();
+    const std::string getStr(const std::wstring & str);
+    const std::string getStr(const std::string & str);
+};
+
+} // namespace CNES
+
+} // namespace slint
+
+#endif // __SLINT_CNES_CSV_RESULT_HXX__
  *
  */
 
-#ifndef __SLINT_CNES_RESULT_HXX__
-#define __SLINT_CNES_RESULT_HXX__
+#ifndef __SLINT_CNES_XML_RESULT_HXX__
+#define __SLINT_CNES_XML_RESULT_HXX__
 
 #include <fstream>
 #include <string>
 #include <unordered_map>
 #include <vector>
 
+#include "config/cnes/ToolConfiguration.hxx"
 #include "output/SLintResult.hxx"
 
 namespace types
@@ -33,8 +34,9 @@ class SciFile;
 namespace CNES
 {
 
-class CNESResult : public SLintResult
+class CNESXmlResult : public SLintResult
 {
+    const ToolConfigurationType tct;
     const std::wstring path;
     std::ofstream * out;
     SciFilePtr current;
@@ -42,11 +44,11 @@ class CNESResult : public SLintResult
 
 public:
 
-    CNESResult(types::String * conf, const std::wstring & id, const std::wstring & _path);
+    CNESXmlResult(const ToolConfiguration & tc, types::String * conf, const std::wstring & id, const std::wstring & _path);
 
-    virtual ~CNESResult();
+    virtual ~CNESXmlResult();
     virtual void handleFiles(const std::vector<SciFilePtr> & files);
-    virtual void handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const std::wstring & msg);
+    virtual void handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg);
     virtual void finalize();
 
 private:
@@ -58,4 +60,4 @@ private:
 
 } // namespace slint
 
-#endif // __SLINT_CNES_RESULT_HXX__
+#endif // __SLINT_CNES_XML_RESULT_HXX__
index 9c986e6..62d20e7 100644 (file)
@@ -16,7 +16,9 @@
 #include "SLint.hxx"
 #include "output/SLintScilabResult.hxx"
 #include "output/SLintXmlResult.hxx"
-#include "output/cnes/CNESResult.hxx"
+#include "output/cnes/CNESXmlResult.hxx"
+#include "output/cnes/CNESCsvResult.hxx"
+#include "config/cnes/ToolConfiguration.hxx"
 #include "config/XMLConfig.hxx"
 
 #include "struct.hxx"
@@ -147,7 +149,17 @@ types::Function::ReturnValue sci_slint(types::typed_list & in, int _iRetCount, t
         {
             if (conf && conf->getSize() >= 2 && (std::wstring(conf->get(0)) == L"cnes"))
             {
-                results = new slint::CNES::CNESResult(conf, options.getId(), outFile->get(0));
+               const slint::CNES::ToolConfiguration tc = slint::CNES::ToolConfiguration::createFromXml(conf->get(1));
+               const std::wstring out(outFile->get(0));
+               const std::size_t pos = out.find_last_of(L'.');
+               if (pos != std::string::npos && out.substr(pos) == L".csv")
+               {
+                   results = new slint::CNES::CNESCsvResult(tc, conf, options.getId(), outFile->get(0));
+               }
+               else
+               {
+                   results = new slint::CNES::CNESXmlResult(tc, conf, options.getId(), outFile->get(0));
+               }
             }
             else
             {
index 1d30a22..1c87ac4 100644 (file)
     <ClInclude Include="includes\config\XMLConfig.hxx" />
     <ClInclude Include="includes\dynlib_slint.h" />
     <ClInclude Include="includes\FileException.hxx" />
+    <ClInclude Include="includes\output\cnes\CNESCsvResult.hxx" />
+    <ClInclude Include="includes\output\cnes\CNESXmlResult.hxx" />
     <ClInclude Include="includes\output\SLintResult.hxx" />
     <ClInclude Include="includes\output\SLintScilabResult.hxx" />
     <ClInclude Include="includes\output\SLintXmlResult.hxx" />
     <ClCompile Include="src\cpp\BracketedExpChecker.cpp" />
     <ClCompile Include="src\cpp\BreaksInLoopChecker.cpp" />
     <ClCompile Include="src\cpp\CNESConfig.cpp" />
+    <ClCompile Include="src\cpp\CNESCsvResult.cpp" />
     <ClCompile Include="src\cpp\CNESException.cpp" />
-    <ClCompile Include="src\cpp\CNESResult.cpp" />
+    <ClCompile Include="src\cpp\CNESXmlResult.cpp" />
     <ClCompile Include="src\cpp\CommentRatioChecker.cpp" />
     <ClCompile Include="src\cpp\DecimalChecker.cpp" />
     <ClCompile Include="src\cpp\DeprecatedChecker.cpp" />
index 338e317..ded907d 100644 (file)
     <ClInclude Include="includes\checkers\ExpInCondChecker.hxx">
       <Filter>Header Files\checkers</Filter>
     </ClInclude>
+    <ClInclude Include="includes\output\cnes\CNESCsvResult.hxx">
+      <Filter>Header Files\output\cnes</Filter>
+    </ClInclude>
+    <ClInclude Include="includes\output\cnes\CNESXmlResult.hxx">
+      <Filter>Header Files\output\cnes</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="src\cpp\BracketedExpChecker.cpp">
     <ClCompile Include="src\cpp\CNESException.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="src\cpp\CNESResult.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="src\cpp\CommentRatioChecker.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="src\cpp\ExpInCondChecker.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\cpp\CNESCsvResult.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\CNESXmlResult.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>
\ No newline at end of file
index aa5a8c5..9327208 100644 (file)
@@ -105,7 +105,7 @@ void CNESConfig::getBool(const AnalysisRuleType & art, const std::string & name,
 
 const std::wstring CNESConfig::getId(const ToolConfigurationType & tct, const AnalysisRuleType & art)
 {
-    auto i = tct.getRuleLink().find(art.getId());
+    /*auto i = tct.getRuleLink().find(art.getId());
     if (i == tct.getRuleLink().end())
     {
         return scilab::UTF8::toWide(art.getId());
@@ -113,7 +113,8 @@ const std::wstring CNESConfig::getId(const ToolConfigurationType & tct, const An
     else
     {
         return scilab::UTF8::toWide(i->second.getStandardRuleId());
-    }
+       }*/
+    return scilab::UTF8::toWide(art.getId());
 }
 
 template<>
diff --git a/scilab/modules/slint/src/cpp/CNESCsvResult.cpp b/scilab/modules/slint/src/cpp/CNESCsvResult.cpp
new file mode 100644 (file)
index 0000000..0520ca9
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2015 - Scilab Enterprises - Calixte DENIZET
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include <chrono>
+#include <ctime>
+#include <string>
+
+#include "output/cnes/CNESCsvResult.hxx"
+#include "checkers/SLintChecker.hxx"
+#include "FileException.hxx"
+#include "SLint.hxx"
+#include "SciFile.hxx"
+#include "UTF8.hxx"
+
+extern "C"
+{
+#include "sci_malloc.h"
+#include "charEncoding.h"
+#include "localization.h"
+}
+
+namespace slint
+{
+
+namespace CNES
+{
+
+    CNESCsvResult::CNESCsvResult(const ToolConfiguration & tc, types::String * conf, const std::wstring & id, const std::wstring & _path) : tct(tc.getToolConfiguration()), current(nullptr), path(_path)
+{
+    std::string projectName;
+    std::string projectVersion;
+    std::string projectAuthor;
+    if (conf)
+    {
+        if (conf->getSize() >= 4)
+        {
+            projectName = getStr(conf->get(3));
+        }
+        if (conf->getSize() >= 5)
+        {
+            projectVersion = getStr(conf->get(4));
+        }
+        if (conf->getSize() >= 6)
+        {
+            projectAuthor = getStr(conf->get(5));
+        }
+    }
+    const std::wstring fullpath = SLint::getFullPath(path);
+    out = new std::ofstream(scilab::UTF8::toUTF8(fullpath), std::ios::out);
+    if (!out->is_open())
+    {
+        delete out;
+        out = nullptr;
+       throw slint::FileException(fullpath, _("Cannot open the file"));
+    }
+    else
+    {
+       (*out) << projectName << ',';
+       (*out) << projectVersion << ',';
+       (*out) << projectAuthor << ',';
+       (*out) << "scilab,";
+
+        std::chrono::time_point<std::chrono::system_clock> point = std::chrono::system_clock::now();;
+        std::time_t time = std::chrono::system_clock::to_time_t(point);
+        std::string date(std::ctime(&time));
+        if (date.back() == '\n')
+        {
+            date = std::string(date.begin(), std::prev(date.end()));
+        }
+        (*out) << getStr(date) << '\n';
+    }
+}
+
+CNESCsvResult::~CNESCsvResult()
+{
+    if (out)
+    {
+        out->close();
+        delete out;
+    }
+}
+
+void CNESCsvResult::finalize()
+{
+    printRes();
+    out->close();
+    delete out;
+    out = nullptr;
+}
+
+void CNESCsvResult::handleFiles(const std::vector<SciFilePtr> & files)
+{
+}
+
+void CNESCsvResult::handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg)
+{
+    if (context.getSciFile().get() != current.get())
+    {
+        printRes();
+        current = context.getSciFile();
+    }
+    res[checker.getId(sub)].emplace_back(loc, msg);
+}
+
+void CNESCsvResult::printRes()
+{
+    if (current.get())
+    {
+        for (const auto & r : res)
+        {
+           const std::string name = scilab::UTF8::toUTF8(r.first);
+           std::string ruleName;
+           auto i = tct.getRuleLink().find(name);
+           if (i == tct.getRuleLink().end())
+           {
+               ruleName = getStr(r.first);
+           }
+           else
+           {
+               ruleName = getStr(scilab::UTF8::toWide(i->second.getStandardRuleId()));
+           }
+            for (const auto & p : r.second)
+            {
+               (*out) << ruleName << ','
+                      << getStr(current->getFilename()) << ','
+                      << getStr(p.second) << ','
+                      << p.first.first_line << ','
+                      << p.first.first_column << '\n';
+            }
+        }
+    }
+    res.clear();
+}
+
+const std::string CNESCsvResult::getStr(const std::wstring & str)
+{
+    std::vector<wchar_t> buf;
+    buf.reserve(str.size() + 2);
+    buf.push_back(L'\"');
+    for (auto c : str)
+    {
+        if (c == L'\"')
+        {
+           buf.push_back(L'\\');
+           buf.push_back(L'\"');
+        }
+        else
+        {
+            buf.push_back(c);
+        }
+    }
+    buf.push_back(L'\"');
+
+    return scilab::UTF8::toUTF8(std::wstring(buf.begin(), buf.end()));
+}
+
+const std::string CNESCsvResult::getStr(const std::string & str)
+{
+    std::vector<char> buf;
+    buf.reserve(str.size() + 2);
+    buf.push_back('\"');
+    for (auto c : str)
+    {
+        if (c == '\"')
+        {
+           buf.push_back('\\');
+           buf.push_back('\"');
+        }
+        else
+        {
+            buf.push_back(c);
+        }
+    }
+    buf.push_back('\"');
+
+    return std::string(buf.begin(), buf.end());
+}
+    
+} // namespace CNES
+
+} // namespace slint
similarity index 76%
rename from scilab/modules/slint/src/cpp/CNESResult.cpp
rename to scilab/modules/slint/src/cpp/CNESXmlResult.cpp
index 5f750ad..dedf6c0 100644 (file)
@@ -15,8 +15,9 @@
 #include <string>
 
 #include "output/SLintXmlResult.hxx"
-#include "output/cnes/CNESResult.hxx"
+#include "output/cnes/CNESXmlResult.hxx"
 #include "checkers/SLintChecker.hxx"
+#include "FileException.hxx"
 #include "SLint.hxx"
 #include "SciFile.hxx"
 #include "UTF8.hxx"
@@ -34,7 +35,7 @@ namespace slint
 namespace CNES
 {
 
-CNESResult::CNESResult(types::String * conf, const std::wstring & id, const std::wstring & _path) : current(nullptr), path(_path)
+    CNESXmlResult::CNESXmlResult(const ToolConfiguration & tc, types::String * conf, const std::wstring & id, const std::wstring & _path) : tct(tc.getToolConfiguration()), current(nullptr), path(_path)
 {
     std::string projectName;
     std::string projectVersion;
@@ -60,6 +61,7 @@ CNESResult::CNESResult(types::String * conf, const std::wstring & id, const std:
     {
         delete out;
         out = nullptr;
+       throw slint::FileException(fullpath, _("Cannot open the file"));
     }
     else
     {
@@ -91,7 +93,7 @@ CNESResult::CNESResult(types::String * conf, const std::wstring & id, const std:
     }
 }
 
-CNESResult::~CNESResult()
+CNESXmlResult::~CNESXmlResult()
 {
     if (out)
     {
@@ -100,7 +102,7 @@ CNESResult::~CNESResult()
     }
 }
 
-void CNESResult::finalize()
+void CNESXmlResult::finalize()
 {
     printRes();
     (*out) << "</analysisProject>\n";
@@ -109,7 +111,7 @@ void CNESResult::finalize()
     out = nullptr;
 }
 
-void CNESResult::handleFiles(const std::vector<SciFilePtr> & files)
+void CNESXmlResult::handleFiles(const std::vector<SciFilePtr> & files)
 {
     for (const auto & file : files)
     {
@@ -118,23 +120,34 @@ void CNESResult::handleFiles(const std::vector<SciFilePtr> & files)
     }
 }
 
-void CNESResult::handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const std::wstring & msg)
+void CNESXmlResult::handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg)
 {
     if (context.getSciFile().get() != current.get())
     {
         printRes();
         current = context.getSciFile();
     }
-    res[checker.getId()].emplace_back(loc, msg);
+    res[checker.getId(sub)].emplace_back(loc, msg);
 }
 
-void CNESResult::printRes()
+void CNESXmlResult::printRes()
 {
     if (current.get())
     {
         for (const auto & r : res)
         {
-            (*out) << "  <analysisRule analysisRuleId=\"" << SLintXmlResult::getStr(r.first) << "\">\n";
+           const std::string name = scilab::UTF8::toUTF8(r.first);
+           std::string ruleName;
+           auto i = tct.getRuleLink().find(name);
+           if (i == tct.getRuleLink().end())
+           {
+               ruleName = SLintXmlResult::getStr(r.first);
+           }
+           else
+           {
+               ruleName = SLintXmlResult::getStr(scilab::UTF8::toWide(i->second.getStandardRuleId()));
+           }
+            (*out) << "  <analysisRule analysisRuleId=\"" << ruleName << "\">\n";
             for (const auto & p : r.second)
             {
                 (*out) << "    <result filename=\"" << SLintXmlResult::getStr(current->getFilename()) << "\""
index cf2d1e2..91aff9e 100644 (file)
@@ -26,6 +26,12 @@ FileException::FileException(const std::wstring & filename, const std::wstring &
     msg = std::string("Error with file ") + scilab::UTF8::toUTF8(filename) + ":\n" + scilab::UTF8::toUTF8(error);
 }
 
+FileException::FileException(const std::wstring & filename, const std::string & error)
+{
+    msg = std::string("Error with file ") + scilab::UTF8::toUTF8(filename) + ":\n" + error;
+}
+
+    
 #ifdef _MSC_VER
 const char * FileException::what() const
 #else
index ae457f8..0f532ee 100644 (file)
@@ -30,7 +30,7 @@ void NestedBlocksChecker::preCheckNode(const ast::Exp & e, SLintContext & contex
 void NestedBlocksChecker::postCheckNode(const ast::Exp & e, SLintContext & context, SLintResult & result)
 {
     if (max >= 0)
-    {
+    { 
        if (!stack.empty())
        {
            stack.erase(std::prev(stack.end()));
index 2847f95..86ebefa 100644 (file)
@@ -38,7 +38,7 @@ extern "C"
 #define DEFAULT_FILESPEC L"*"
 #endif
 
-#define SLINT_PRINT_AST
+//#define SLINT_PRINT_AST
 #ifdef SLINT_PRINT_AST
 #include "prettyprintvisitor.hxx"
 #endif
index 5664951..e276323 100644 (file)
@@ -71,4 +71,10 @@ const std::wstring & SLintChecker::getId() const
 {
     return checkerId;
 }
+
+const std::wstring SLintChecker::getId(const unsigned sub) const
+{
+    return sub ? L"" : getId();
+}
+    
 }
index e09786f..6adbed2 100644 (file)
@@ -25,10 +25,10 @@ namespace slint
 SLintScilabResult::SLintScilabResult() { }
 SLintScilabResult::~SLintScilabResult() { }
 
-void SLintScilabResult::handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const std::wstring & msg)
+void SLintScilabResult::handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg)
 {
     auto & mmap = results[context.getFilename()];
-    mmap.emplace(loc, checker.getId() + L": " + msg);
+    mmap.emplace(loc, checker.getId(sub) + L": " + msg);
 }
 
 void SLintScilabResult::finalize()
@@ -48,9 +48,9 @@ void SLintScilabResult::finalize()
 SLintScilabOut::SLintScilabOut() { }
 SLintScilabOut::~SLintScilabOut() { }
 
-void SLintScilabOut::handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const std::wstring & msg)
+void SLintScilabOut::handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg)
 {
-    results[context.getFilename()][checker.getId()].emplace_back(loc, msg);
+    results[context.getFilename()][checker.getId(sub)].emplace_back(loc, msg);
 }
 
 void SLintScilabOut::finalize()
index 60b327c..32634f8 100644 (file)
@@ -68,7 +68,7 @@ const std::string SLintXmlResult::getStr(const std::wstring & str)
     return scilab::UTF8::toUTF8(replaceByEntities(str));
 }
 
-void SLintXmlResult::handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const std::wstring & msg)
+    void SLintXmlResult::handleMessage(SLintContext & context, const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg)
 {
     if (context.getSciFile().get() != current.get())
     {
@@ -79,7 +79,7 @@ void SLintXmlResult::handleMessage(SLintContext & context, const Location & loc,
         current = context.getSciFile();
         print(current);
     }
-    print(loc, checker, msg);
+    print(loc, checker, sub, msg);
 }
 
 void SLintXmlResult::print(const SciFilePtr & file)
@@ -87,11 +87,11 @@ void SLintXmlResult::print(const SciFilePtr & file)
     (*out) << "  <File name=\"" << getStr(file->getFilename()) << "\">\n";
 }
 
-void SLintXmlResult::print(const Location & loc, const SLintChecker & checker, const std::wstring & msg)
+void SLintXmlResult::print(const Location & loc, const SLintChecker & checker, const unsigned sub, const std::wstring & msg)
 {
     (*out) << "    <Result>\n";
     print(loc);
-    print(checker);
+    print(checker, sub);
     print(msg);
     (*out) << "    </Result>\n";
 }
@@ -105,10 +105,10 @@ void SLintXmlResult::print(const Location & loc)
            << "\"/>\n";
 }
 
-void SLintXmlResult::print(const SLintChecker & checker)
+    void SLintXmlResult::print(const SLintChecker & checker, const unsigned sub)
 {
     (*out) << "      <Checker name=\"" << checker.getName()
-           << "\" id=\"" << getStr(checker.getId())
+           << "\" id=\"" << getStr(checker.getId(sub))
            << "\"/>\n";
 }
 
@@ -125,23 +125,23 @@ std::wstring SLintXmlResult::replaceByEntities(const std::wstring & seq)
     {
         if (c == L'<')
         {
-            pushEntity(buf, L"&lt;", 7);
+            pushEntity(buf, L"&lt;", 4);
         }
         else if (c == L'>')
         {
-            pushEntity(buf, L"&gt;", 7);
+            pushEntity(buf, L"&gt;", 4);
         }
         else if (c == L'\'')
         {
-            pushEntity(buf, L"&apos;", 7);
+            pushEntity(buf, L"&apos;", 6);
         }
         else if (c == L'\"')
         {
-            pushEntity(buf, L"&quot;", 7);
+            pushEntity(buf, L"&quot;", 6);
         }
         else if (c == L'&')
         {
-            pushEntity(buf, L"&amp;", 7);
+            pushEntity(buf, L"&amp;", 5);
         }
         else
         {
index 4405e19..f587f3f 100644 (file)
@@ -99,7 +99,7 @@ void VariablesChecker::preCheckNode(const ast::Exp & e, SLintContext & context,
                                 {
                                     if (!pIT->isFunction() && !pIT->isMacroFile() && !pIT->isMacro())
                                     {
-                                        result.report(context, e.getLocation(), *this, _("Use of non-initialized variable \'%s\' may have any side-effects."), name);
+                                        result.report(context, e.getLocation(), *this, 1, _("Use of non-initialized variable \'%s\' may have any side-effects."), name);
                                     }
                                 }
                                 else if (!context.isPrivateFunction(sym))
@@ -118,12 +118,12 @@ void VariablesChecker::preCheckNode(const ast::Exp & e, SLintContext & context,
                                     std::wstring fname;
                                     if (context.isExternPrivateFunction(sym, fname))
                                     {
-                                        result.report(context, e.getLocation(), *this, _("Use of a private macro \'%s\' defined in an other file %s."), name, fname);
+                                        result.report(context, e.getLocation(), *this, 3, _("Use of a private macro \'%s\' defined in an other file %s."), name, fname);
                                     }
                                     else if (!context.getPublicFunction(sym.getName()))
                                     {
                                         // The macro has not been declared somewhere in the project
-                                        result.report(context, e.getLocation(), *this, _("Use of non-initialized variable \'%s\' may have side effects."), name);
+                                        result.report(context, e.getLocation(), *this, 1, _("Use of non-initialized variable \'%s\' may have side effects."), name);
                                     }
                                 }
                             }
@@ -187,7 +187,7 @@ void VariablesChecker::postCheckNode(const ast::Exp & e, SLintContext & context,
         {
             if (!std::get<1>(p.second)) // the variable has an explicit assignment, i.e. we are not in the case for i=1:10...
             {
-                result.report(context, std::get<0>(p.second), *this, _("Declared variable and might be unused: %s."), p.first);
+                result.report(context, std::get<0>(p.second), *this, 2, _("Declared variable and might be unused: %s."), p.first);
             }
         }
         assigned.pop();
@@ -210,4 +210,21 @@ const std::string VariablesChecker::getName() const
 {
     return "VariablesChecker";
 }
+
+const std::wstring VariablesChecker::getId(const unsigned sub) const
+{
+    switch (sub)
+    {
+    case 0:
+       return SLintChecker::getId();
+    case 1:
+       return SLintChecker::getId() + L".Uninitialized";
+    case 2:
+       return SLintChecker::getId() + L".Unused";
+    case 3:
+       return SLintChecker::getId() + L".PrivateMacro";
+    default:
+       return L"";
+    }
+}
 }