Tools__CodeCritics.st
author Jan Vrany <jan.vrany@labware.com>
Wed, 05 Oct 2022 11:57:26 +0100
branchjv
changeset 19637 28f5bfaa093d
parent 18532 cccb41254edf
permissions -rw-r--r--
`NewSystemBrowser`: avoid updating package info when changed class is not selected This speeds up loading of packages when browser is open as it does not (needlessly) update package info which may involve scm round-trip.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18532
cccb41254edf Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents: 12431
diff changeset
     1
"{ Encoding: utf8 }"
cccb41254edf Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents: 12431
diff changeset
     2
7770
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 2007 by eXept Software AG
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
              All Rights Reserved
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libtool' }"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
"{ NameSpace: Tools }"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
Object subclass:#CodeCritics
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	instanceVariableNames:'code critics'
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Interface-Browsers-New'
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!CodeCritics class methodsFor:'documentation'!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
copyright
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 2007 by eXept Software AG
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
              All Rights Reserved
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
documentation
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    extracted critics from the browser
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    For now, not much is found here - however, it will eventually grow and should collect
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    the critics in the parser as well.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    [author:]
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
        Claus Gittinger (cg@exept.de)
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
! !
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
!CodeCritics class methodsFor:'critics'!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
checkCodeQuality:code
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    ^ (self new code:code) checkCodeQuality
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    "Created: / 27-03-2007 / 21:41:50 / cg"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
! !
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
!CodeCritics methodsFor:'accessing'!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
code:something
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    code := something.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
! !
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
!CodeCritics methodsFor:'critics'!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
7780
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    68
checkBadIndentationOfReturns
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    69
    "we want returns to be indented correctly"
7770
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    code asCollectionOfLines keysAndValuesDo:[:lineNr :eachLine |
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
        |lineString column|
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
        lineString := eachLine string.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
        (lineString withoutLeadingSeparators startsWith:'^') ifTrue:[
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
            column := lineString indexOf:$^.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
            (column-1) \\ 4 ~~ 0 ifTrue:[
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
                self addCritic:'bad indentation' line:lineNr.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
            ].
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
        ]
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    ].
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    "Created: / 27-03-2007 / 21:41:10 / cg"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
checkCodeQuality
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    self checkBadIndentationOfReturns.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    ^ critics
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    "Created: / 27-03-2007 / 21:42:11 / cg"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
! !
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
7780
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    93
!CodeCritics methodsFor:'helpers'!
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    94
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    95
addCritic:msg line:lineNr
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    96
    critics isNil ifTrue:[
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    97
        critics := OrderedCollection new.
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    98
    ].
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    99
    critics add:(lineNr -> msg)
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
   100
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
   101
    "Created: / 27-03-2007 / 21:47:09 / cg"
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
   102
! !
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
   103
7770
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
!CodeCritics class methodsFor:'documentation'!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
10033
Claus Gittinger <cg@exept.de>
parents: 7780
diff changeset
   106
version_CVS
18532
cccb41254edf Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents: 12431
diff changeset
   107
    ^ '§Header: /cvs/stx/stx/libtool/Tools__CodeCritics.st,v 1.3 2011/07/03 13:31:36 cg Exp §'
10033
Claus Gittinger <cg@exept.de>
parents: 7780
diff changeset
   108
!
Claus Gittinger <cg@exept.de>
parents: 7780
diff changeset
   109
12431
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   110
version_HG
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   111
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   112
    ^ '$Changeset: <not expanded> $'
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   113
!
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   114
10033
Claus Gittinger <cg@exept.de>
parents: 7780
diff changeset
   115
version_SVN
12128
a7ff7d66ee85 Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12123
diff changeset
   116
    ^ '$Id: Tools__CodeCritics.st 7854 2012-01-30 17:49:41Z vranyj1 $'
12431
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   117
! !
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   118