reports/Builder__LintReportFormat.st
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:54:38 +0100
changeset 542 aa25a71be62a
parent 266 2ca2606e89e8
permissions -rw-r--r--
#DOCUMENTATION by cg
class: stx_goodies_builder_quickSelfTest
class definition

class: stx_goodies_builder_quickSelfTest class
added:18 methods
     1 "{ Package: 'stx:goodies/builder/reports' }"
     2 
     3 "{ NameSpace: Builder }"
     4 
     5 ReportFormat subclass:#LintReportFormat
     6 	instanceVariableNames:''
     7 	classVariableNames:''
     8 	poolDictionaries:''
     9 	category:'Builder-Reports-Formats'
    10 !
    11 
    12 LintReportFormat subclass:#CheckStyle
    13 	instanceVariableNames:''
    14 	classVariableNames:''
    15 	poolDictionaries:''
    16 	privateIn:LintReportFormat
    17 !
    18 
    19 LintReportFormat subclass:#PMD
    20 	instanceVariableNames:''
    21 	classVariableNames:''
    22 	poolDictionaries:''
    23 	privateIn:LintReportFormat
    24 !
    25 
    26 
    27 !LintReportFormat class methodsFor:'testing'!
    28 
    29 isAbstract
    30 
    31     ^self == LintReportFormat
    32 
    33     "Created: / 04-08-2011 / 11:44:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    34 ! !
    35 
    36 !LintReportFormat methodsFor:'writing'!
    37 
    38 writeFile: filename with: block
    39 
    40     "Writes a section for given file"
    41 
    42     stream tab; nextPutAll:'<file name="'; nextPutAll:filename; nextPutAll: '">'; cr.
    43     block valueWithOptionalArgument: self.
    44     stream tab; nextPutAll:'</file>'; cr.
    45 
    46     "Created: / 07-10-2011 / 10:40:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    47 ! !
    48 
    49 !LintReportFormat::CheckStyle class methodsFor:'accessing'!
    50 
    51 symbolicNames
    52     "Returns a collection of symbolic names for this format"
    53 
    54     ^#(checkstyle)
    55 
    56     "Modified: / 04-08-2011 / 14:23:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    57 ! !
    58 
    59 !LintReportFormat::CheckStyle methodsFor:'accessing - defaults'!
    60 
    61 defaultFileSuffix
    62 
    63     ^ 'xml'
    64 
    65     "Modified: / 08-10-2011 / 10:47:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    66 ! !
    67 
    68 !LintReportFormat::CheckStyle methodsFor:'writing'!
    69 
    70 writeFile: filename with: block
    71 
    72     "Writes a section for given file"
    73 
    74     stream tab; nextPutAll:'<file name="'; nextPutAll:filename; nextPutAll: '">'; cr.
    75     block valueWithOptionalArgument: self.
    76     stream tab; nextPutAll:'</file>'; cr.
    77 
    78     "Created: / 07-10-2011 / 10:40:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    79 !
    80 
    81 writeFooter
    82 
    83     stream nextPutAll: '</checkstyle>'
    84 
    85     "Modified: / 04-08-2011 / 14:42:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    86 !
    87 
    88 writeHeader
    89 
    90     stream nextPutAll: '<?xml version="1.0" encoding="UTF-8"?>'; nextPut: Character lf.
    91     stream nextPutAll: '<checkstyle version="5.4">'; nextPut: Character lf.
    92 
    93     "Modified: / 06-10-2011 / 23:50:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    94 !
    95 
    96 writeViolation:rule class: aClass selector: aSelector startLine:line column:column stopLine:lineStop column:columnStop
    97 
    98     | severity |
    99 
   100     rule severity = #information ifTrue:[
   101         severity := 'info'
   102     ] ifFalse:[
   103         rule severity = #warning ifTrue:[
   104             severity := 'warning'
   105         ] ifFalse:[
   106             severity := 'error'
   107         ]
   108     ].
   109 
   110     stream tab; tab; nextPutAll:'<error'.
   111     stream nextPutAll:' source="'; nextPutAll:(self encode:rule class name); nextPut:$".
   112     stream nextPutAll:' message="'; nextPutAll:(self encode:rule name ); nextPut:$".
   113 
   114     stream nextPutAll:' severity="'; nextPutAll: severity; nextPut:$".
   115     stream nextPutAll:' line="'; nextPutAll:line printString; nextPut:$".
   116     column <= 1 ifFalse:[
   117         stream nextPutAll:' column="'; nextPutAll:column printString; nextPut:$"
   118     ].
   119     stream nextPutAll:'/>'; cr.
   120 
   121     "Created: / 25-11-2011 / 22:23:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   122 ! !
   123 
   124 !LintReportFormat::PMD methodsFor:'accessing - defaults'!
   125 
   126 defaultFileSuffix
   127 
   128     ^ 'xml'
   129 
   130     "Modified: / 08-10-2011 / 10:47:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   131 ! !
   132 
   133 !LintReportFormat::PMD methodsFor:'writing'!
   134 
   135 writeFooter
   136 
   137     stream nextPutAll: '</pmd>'
   138 
   139     "Modified: / 25-11-2011 / 19:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   140 !
   141 
   142 writeHeader
   143 
   144     stream nextPutAll: '<?xml version="1.0" encoding="UTF-8"?>'; nextPut: Character lf.
   145     stream 
   146         nextPutAll: '<pmd version="4.3" timestamp="'; 
   147         nextPutAll: Timestamp now printString;
   148         nextPutAll:'">';
   149         nextPut: Character lf.
   150 
   151     "Modified: / 25-11-2011 / 19:39:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   152 !
   153 
   154 writeViolation:rule class: aClass selector: aSelector startLine:beginLine column:beginColumn stopLine:endLine column:endColumn
   155 
   156     | priority |
   157 
   158     rule severity = #information ifTrue:[
   159         priority := '1'
   160     ] ifFalse:[
   161         rule severity = #warning ifTrue:[
   162             priority := '2'
   163         ] ifFalse:[
   164             priority := '3'
   165         ]
   166     ].
   167 
   168     stream nextPutAll:'<violation '.
   169 
   170     stream nextPutAll:'beginline="';nextPutAll: beginLine printString; nextPut:$"; cr.
   171     stream nextPutAll:'begincolumn="';nextPutAll: beginColumn printString; nextPut:$"; cr.
   172     stream nextPutAll:'endline="';nextPutAll: endLine printString; nextPut:$"; cr.
   173     stream nextPutAll:'endcolumn="';nextPutAll: endColumn printString; nextPut:$"; cr.
   174 
   175     stream nextPutAll:'rule="';nextPutAll: (self encode:rule class name); nextPut:$"; cr.
   176     stream nextPutAll:'ruleset="';nextPutAll: (self encode:rule group); nextPut:$"; cr.
   177 
   178     stream nextPutAll:'package="';nextPutAll: aClass package; nextPut:$"; cr.
   179     stream nextPutAll:'class="';nextPutAll: aClass name; nextPut:$"; cr.
   180 
   181     aSelector notNil ifTrue:[
   182         stream nextPutAll:'method="';nextPutAll: aSelector; nextPut:$"; cr.
   183     ].
   184 
   185     stream nextPutAll:'><!![CDATA['; cr.
   186     stream nextPutAll: (self encode: rule rationale); cr.
   187     stream nextPutAll:']]></violation>'; cr; cr.
   188     stream flush.
   189 
   190     "Created: / 25-11-2011 / 22:28:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   191 ! !
   192 
   193 !LintReportFormat class methodsFor:'documentation'!
   194 
   195 version
   196     ^ '$Header$'
   197 !
   198 
   199 version_CVS
   200     ^ '$Header$'
   201 !
   202 
   203 version_SVN
   204     ^ '$Id$'
   205 ! !
   206