reports/Builder__LintReport.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 06 Jun 2014 10:36:27 +0200
changeset 239 517a62e9f9ab
parent 233 8ea8b3692704
child 254 9272fef1d474
permissions -rw-r--r--
Display one-char messages to make output shorter. F...forking W...waiting for child to finish T...timeout K...testcase killed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/builder/reports' }"
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Builder }"
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
Report subclass:#LintReport
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	instanceVariableNames:'environment rules'
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	category:'Builder-Reports'
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
!LintReport methodsFor:'accessing - defaults'!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
defaultFileSuffix
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
    ^ 'Lint'
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
    "Modified: / 08-10-2011 / 10:49:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
defaultFormat
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
    "raise an error: must be redefined in concrete subclass(es)"
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
    ^ LintReportFormat::PMD new
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
    "Modified: / 25-11-2011 / 22:06:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
79
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
    28
!
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
    29
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
    30
defaultName
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
    31
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
    32
    environment isNil ifTrue:[^super defaultName].
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
    33
    ^environment label
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
    34
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
    35
    "Modified: / 25-11-2011 / 22:06:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
    36
    "Created: / 13-01-2012 / 12:43:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
! !
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
117
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    39
!LintReport methodsFor:'command line options'!
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    40
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    41
cmdlineOptionRuleset
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    42
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    43
    ^CmdLineOption new
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    44
        short: $s;
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    45
        long: 'ruleset';
233
8ea8b3692704 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 203
diff changeset
    46
        description: 'defines set of rules to check against.';
117
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    47
        action:[:option |
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    48
            self setupRulesFrom: option.
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    49
        ];
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    50
        yourself
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    51
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    52
    "Created: / 28-02-2013 / 23:13:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
233
8ea8b3692704 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 203
diff changeset
    53
    "Modified: / 27-05-2014 / 16:54:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
117
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    54
! !
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
    55
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
!LintReport methodsFor:'generating'!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
generateClass: aClass
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    59
        | sourceInfo sourceName |
203
297a4be47446 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 162
diff changeset
    60
        sourceInfo := ReportSourceInfo forClass: aClass.
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
        sourceName := self encodeFilename: (self sourceFilenameFor: aClass).
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
        format writeFile: sourceName with: [
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    64
            self generateClass: aClass source: sourceInfo.
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    65
            self generateClass: aClass class source: sourceInfo.
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
        ].
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    68
        format writeSource: sourceInfo contents to: sourceName
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
    "Created: / 06-10-2011 / 23:54:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
203
297a4be47446 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 162
diff changeset
    71
    "Modified: / 29-07-2013 / 14:47:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    74
generateClass: aClass selector: aSelector source: sourceInfo
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    75
        | matching |
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
        matching := rules select: [ :each | 
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
                (self isSelectorEnvironment: each result)
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
                        and: [ each result includesSelector: aSelector in: aClass ] ].
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    79
        self generateViolations: matching class: aClass selector: aSelector source: sourceInfo
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
    "Created: / 07-10-2011 / 11:04:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    82
    "Modified: / 01-03-2013 / 18:10:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    85
generateClass: aClass source: sourceInfo 
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    87
        | matching |
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
        (environment definesClass: aClass) ifTrue: [
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
                matching := rules select: [ :rule |
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
                        (self isClassEnvironment: rule result)
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
                                and: [ rule result includesClass: aClass ] ].
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    92
                self generateViolations: matching class: aClass selector: nil  source: sourceInfo].
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
        (environment selectorsForClass: aClass) asSortedCollection
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    94
                do: [ :selector | self generateClass: aClass selector: selector source: sourceInfo]
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
    "Created: / 07-10-2011 / 10:29:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    97
    "Modified: / 01-03-2013 / 18:11:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   100
generateViolations: aCollection class: aClass selector: aSelector source: sourceInfo
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   101
    | method offset  |
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   103
    method := aClass compiledMethodAt: aSelector.
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   104
    offset := sourceInfo offsetOfMethod: method.
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
    aCollection do: [ :rule |
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
        | interval start stop |
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
    
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   108
        interval := (rule result selectionIntervalFor: method source) isNil ifTrue: [ 1 to: method source size ].
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   109
        start := sourceInfo lineAndColumnOfOffset: offset + interval first - 1.
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   110
        stop  := sourceInfo lineAndColumnOfOffset: offset + interval last - 1.
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
        format writeViolation: rule
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
                   class: aClass selector: aSelector
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   114
               startLine: start x column: start y
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   115
                stopLine: stop x  column: stop  y.
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
    ]
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   118
    "Created: / 01-03-2013 / 18:05:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
! !
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
!LintReport methodsFor:'initialization'!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
setupForClasses: classes
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
    environment := BrowserEnvironment new forClasses: classes.
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
    environment label: name
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
    "Created: / 04-08-2011 / 14:40:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
setupForPackages: packages
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
79
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
   133
    packages isEmpty ifTrue:[^self].
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
    environment := PackageEnvironment 
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
                    onEnvironment: BrowserEnvironment new
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
                    packageNames: packages.
79
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
   137
    name isNil ifTrue:[
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
   138
        packages size > 1 ifTrue:[
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
   139
            name :=  packages size printString , ' packages'.
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
   140
        ] ifFalse:[
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
   141
            name :=  packages anElement
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
   142
        ]
889d3747a0a8 Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 71
diff changeset
   143
    ].
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
    environment label: name.
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
    "
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
        LintReport runPackage:'stx:goodies/monticello'.
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
        LintReport runPackage:'stx:libjava'
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
    "
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
    "Created: / 04-08-2011 / 14:40:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
! !
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
!LintReport methodsFor:'private'!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
lineAndColumn: aString at: anInteger
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
	| line last stream |
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
	line := 1.
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
	last := 0.
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
	stream := aString readStream.
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   162
	[ (stream nextLine isNil or: [ anInteger <= stream position ])
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
		ifTrue: [ ^ line @ (anInteger - last) ].
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   164
	last := stream position.
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
	line := line + 1 ]
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
		repeat
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   169
sourceFilenameFor: aClass
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   171
    | fn cls |
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   172
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   173
    cls := aClass theNonMetaclass.
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   174
    fn := cls package asString replaceAll:$: with:$_;replaceAll:$/ with:$_.
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   175
    fn := fn , '_' , (cls asString copyReplaceAll:$: with: $_), '.' , cls programmingLanguage sourceFileSuffix.
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
    
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   177
    ^self encodeFilename: fn.
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   178
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
    "
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
        Builder::LintReportFormat::CheckStyle basicNew
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   181
            sourceFilenameFor: Class
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
        Builder::LintReportFormat::CheckStyle basicNew
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   184
            sourceFilenameFor: Builder::LintReportFormat
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
    "
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
    "Created: / 07-10-2011 / 09:06:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
118
7e93ef8c5417 Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   188
    "Modified: / 01-03-2013 / 18:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
! !
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
!LintReport methodsFor:'running'!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   192
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   193
runReport
82
e676efa2a286 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   194
    | wasTryLocalSources |
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
82
e676efa2a286 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   196
    [
e676efa2a286 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   197
        wasTryLocalSources := Class tryLocalSourceFirst.
84
77e12dbe97d3 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 82
diff changeset
   198
        Class tryLocalSourceFirst: true.
82
e676efa2a286 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   199
        SmalllintChecker 
e676efa2a286 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   200
            runRule: (RBCompositeLintRule rules: rules)
e676efa2a286 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   201
            onEnvironment: environment.
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
82
e676efa2a286 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   203
        (environment classes asSortedCollection: [ :a :b | a name <= b name ])
e676efa2a286 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   204
            do: [ :class | self generateClass: class].
e676efa2a286 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   205
    ] ensure:[
e676efa2a286 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   206
        Class tryLocalSourceFirst: wasTryLocalSources 
e676efa2a286 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   207
    ]
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
84
77e12dbe97d3 changed: #runReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 82
diff changeset
   209
    "Modified: / 23-01-2012 / 09:04:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   212
setUp
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   213
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   214
    super setUp.
117
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   215
    rules isNil ifTrue:[
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   216
        rules := (RBCompositeLintRule rulesFor: RBBasicLintRule)
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   217
                 reject: [ :each | each class name endsWith: 'SpellingRule' ]
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   218
    ].
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   219
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   220
    "Created: / 04-08-2011 / 14:35:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
117
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   221
    "Modified: / 28-02-2013 / 23:18:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   222
!
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   223
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   224
setupRulesFrom: filename
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   225
    | file |    
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   226
    file := filename asFilename.
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   227
    file readingFileDo:[:s|
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   228
        | spec |
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   229
        spec := Parser parseLiteralArray: s.
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   230
        rules := spec decodeAsLiteralArray rules.
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   231
    ]
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   232
d7f87303b984 class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 84
diff changeset
   233
    "Created: / 28-02-2013 / 23:17:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   234
! !
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   235
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   236
!LintReport methodsFor:'testing'!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   237
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   238
isClassEnvironment: anEnvironment
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   239
	^ #(CategoryEnvironment ClassEnvironment VariableEnvironment) includes: anEnvironment class name
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   240
!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   241
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   242
isSelectorEnvironment: anEnvironment
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   243
	^ #(SelectorEnvironment ParseTreeEnvironment VariableEnvironment) includes: anEnvironment class name
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   244
! !
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   245
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   246
!LintReport class methodsFor:'documentation'!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   247
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   248
version
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   249
    ^ '$Header$'
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   250
!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   251
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   252
version_CVS
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   253
    ^ '$Header$'
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   254
!
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   255
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   256
version_SVN
162
1dbab63ebbd5 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 141
diff changeset
   257
    ^ '$Id$'
71
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   258
! !
1ed7c6cb2f68 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   259