Tools__CodeCritics.st
author Claus Gittinger <cg@exept.de>
Mon, 20 Jan 2020 21:02:47 +0100
changeset 19422 c6ca1c3e0fd7
parent 10033 3eb9c528ede6
child 12123 4bde08cebd48
permissions -rw-r--r--
#REFACTORING by exept class: MultiViewToolApplication added: #askForFile:default:forSave:thenDo: changed: #askForFile:default:thenDo: #askForFile:thenDo: #menuSaveAllAs #menuSaveAs

"
 COPYRIGHT (c) 2007 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libtool' }"

"{ NameSpace: Tools }"

Object subclass:#CodeCritics
	instanceVariableNames:'code critics'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Browsers-New'
!

!CodeCritics class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2007 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    extracted critics from the browser
    For now, not much is found here - however, it will eventually grow and should collect
    the critics in the parser as well.

    [author:]
        Claus Gittinger (cg@exept.de)
"
! !

!CodeCritics class methodsFor:'critics'!

checkCodeQuality:code
    ^ (self new code:code) checkCodeQuality

    "Created: / 27-03-2007 / 21:41:50 / cg"
! !

!CodeCritics methodsFor:'accessing'!

code:something
    code := something.
! !

!CodeCritics methodsFor:'critics'!

checkBadIndentationOfReturns
    "we want returns to be indented correctly"

    code asCollectionOfLines keysAndValuesDo:[:lineNr :eachLine |
        |lineString column|

        lineString := eachLine string.
        (lineString withoutLeadingSeparators startsWith:'^') ifTrue:[
            column := lineString indexOf:$^.
            (column-1) \\ 4 ~~ 0 ifTrue:[
                self addCritic:'bad indentation' line:lineNr.
            ].
        ]
    ].

    "Created: / 27-03-2007 / 21:41:10 / cg"
!

checkCodeQuality
    self checkBadIndentationOfReturns.
    ^ critics

    "Created: / 27-03-2007 / 21:42:11 / cg"
! !

!CodeCritics methodsFor:'helpers'!

addCritic:msg line:lineNr
    critics isNil ifTrue:[
        critics := OrderedCollection new.
    ].
    critics add:(lineNr -> msg)

    "Created: / 27-03-2007 / 21:47:09 / cg"
! !

!CodeCritics class methodsFor:'documentation'!

version_CVS
    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeCritics.st,v 1.3 2011-07-03 13:31:36 cg Exp $'
!

version_SVN
    ^ '§Id: Tools__CodeCritics.st 7487 2009-10-28 21:11:04Z vranyj1 §'
! !