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