Coder Social home page Coder Social logo

Swift langage support about lizard HOT 21 CLOSED

terryyin avatar terryyin commented on August 17, 2024
Swift langage support

from lizard.

Comments (21)

terryyin avatar terryyin commented on August 17, 2024

Great idea! I’m going to implement it next week after I study the language a bit.

On 21 Jul 2015, at 3:29 pm, kenji21 [email protected] wrote:

We are using lizard on objc project (thanks you for this nice tool that improve xcode using a simple script), is there any chances that brand new Swift language will be supported ?

I have no idea on how to add support for it, maybe some indication will help to support it.


Reply to this email directly or view it on GitHub #61.

from lizard.

kenji21 avatar kenji21 commented on August 17, 2024

Wow, nice :-D

from lizard.

terryyin avatar terryyin commented on August 17, 2024

Hi @kenji21 ,
it has been a while. I finally did something with Swift.
I added a new option -l, which can filter the languages:
lizard -lswift <folder_name>

will analyse swift code only, otherwise it will process all file types it knows.

This is only a draft version for Swift support. I’m not sure if it’s completed yet. I don’t know much about Swift myself.
There’s at least one open issue, there seems to be nested functions in Swift,
is it common?
How do you want to count for nested functions?

terry

from lizard.

kenji21 avatar kenji21 commented on August 17, 2024

Hi terry, nice to have some advancement on this.

Unfortunately I haven't switched to fulltime dev using swift yet. So I can't respond to your question.

Maybe having a look at these "swift grammar" files of the tailor project can help : https://github.com/sleekbyte/tailor/tree/master/src/test/swift/com/sleekbyte/tailor/grammar

from lizard.

terryyin avatar terryyin commented on August 17, 2024

Thanks!

from lizard.

kenji21 avatar kenji21 commented on August 17, 2024

Cool, it also can find swift and objc issues :

lizard --CCN 12 --ignore_warnings 20 --working_threads 4 -w
./ATvhClient/EPGCollectionViewLayout.swift:12: warning: durationInHourForItemAtIndexPath has 16 CCN and 1 params (71 NLOC, 595 tokens)
./tvheadend-ios-lib/tvheadend-ios-lib/SSHWrapper.m:214: warning: setPortForwardFromPort: toHost: onPort: has 29 CCN and 0 params (134 NLOC, 853 tokens)

from lizard.

terryyin avatar terryyin commented on August 17, 2024

There’s also a new option -l to select the language, e.g.
lizard -lswift -lobjc

will only search for swift and objective-c code.

On 16 Dec 2015, at 4:18 PM, kenji21 [email protected] wrote:

Cool, it also can find swift an objc issues :

lizard --CCN 12 --ignore_warnings 20 --working_threads 4 -w
./ATvhClient/EPGCollectionViewLayout.swift:12: warning: durationInHourForItemAtIndexPath has 16 CCN and 1 params (71 NLOC, 595 tokens)
./tvheadend-ios-lib/tvheadend-ios-lib/SSHWrapper.m:214: warning: setPortForwardFromPort: toHost: onPort: has 29 CCN and 0 params (134 NLOC, 853 tokens)

Reply to this email directly or view it on GitHub #61 (comment).

from lizard.

kenji21 avatar kenji21 commented on August 17, 2024

Ok, surprising that the EPGCollectionViewLayout.swift:12 is a method of an interface :

protocol EPGCollectionViewLayoutDelegate {
    func durationInHourForItemAtIndexPath(indexPath: NSIndexPath) -> Double
    func startDateForItemAtIndexPath(indexPath: NSIndexPath) -> NSDate
}

from lizard.

terryyin avatar terryyin commented on August 17, 2024

Congrats! you just found a bug! Thanks.

I thought adding Swift shouldn’t be that easy… I will fix it asap.

On 16 Dec 2015, at 4:24 PM, kenji21 [email protected] wrote:

Ok, surprising that the EPGCollectionViewLayout.swift:12 is a method of an interface :

protocol EPGCollectionViewLayoutDelegate {
func durationInHourForItemAtIndexPath(indexPath: NSIndexPath) -> Double
func startDateForItemAtIndexPath(indexPath: NSIndexPath) -> NSDate
}

Reply to this email directly or view it on GitHub #61 (comment).

from lizard.

terryyin avatar terryyin commented on August 17, 2024

Hi @Jenji21 ,

I just made a new release. It will be great if you can try it at your convenience.

terry

On 16 Dec 2015, at 4:27 PM, Terry [email protected] wrote:

Congrats! you just found a bug! Thanks.

I thought adding Swift shouldn’t be that easy… I will fix it asap.

On 16 Dec 2015, at 4:24 PM, kenji21 <[email protected] mailto:[email protected]> wrote:

Ok, surprising that the EPGCollectionViewLayout.swift:12 is a method of an interface :

protocol EPGCollectionViewLayoutDelegate {
func durationInHourForItemAtIndexPath(indexPath: NSIndexPath) -> Double
func startDateForItemAtIndexPath(indexPath: NSIndexPath) -> NSDate
}

Reply to this email directly or view it on GitHub #61 (comment).

from lizard.

kenji21 avatar kenji21 commented on August 17, 2024

Just tried, now it's on the next method of the protocol (edit: which is the last one) :

lizard  --CCN 12 --ignore_warnings 20 --working_threads 4 -w
./ATvhClient/EPGCollectionViewLayout.swift:13: warning: startDateForItemAtIndexPath has 16 CCN and 1 params (70 NLOC, 585 tokens)

from lizard.

terryyin avatar terryyin commented on August 17, 2024

do you mind send me the file or the context?

On 16 Dec 2015, at 4:45 PM, kenji21 [email protected] wrote:

Just tried, now it's on the next method of the protocol :

lizard --CCN 12 --ignore_warnings 20 --working_threads 4 -w
./ATvhClient/EPGCollectionViewLayout.swift:13: warning: startDateForItemAtIndexPath has 16 CCN and 1 params (70 NLOC, 585 tokens)

Reply to this email directly or view it on GitHub #61 (comment).

from lizard.

kenji21 avatar kenji21 commented on August 17, 2024

Sure, this project will be open-sourced soon :-)

EPGCollectionViewLayout.swift.zip

from lizard.

terryyin avatar terryyin commented on August 17, 2024

thanks for sharing.

Now the problem is fixed.

from lizard.

kenji21 avatar kenji21 commented on August 17, 2024

Cool, seems to work well on Apple Lister sample:

https://developer.apple.com/library/ios/samplecode/Lister/Introduction/Intro.html

from lizard.

foobra avatar foobra commented on August 17, 2024

One question @terryyin
the function name is too short so we can't distinguish between functions

screen shot 2017-08-09 at 21 10 37

from lizard.

terryyin avatar terryyin commented on August 17, 2024

@foobra could you also provide the swift code?

from lizard.

foobra avatar foobra commented on August 17, 2024

@terryyin

https://gist.github.com/foobra/f0a8cc1fcd3ef2081e1b6eb6cbc70e25
lizard -l swift -s cyclomatic_complexity -X demo.swift

from lizard.

foobra avatar foobra commented on August 17, 2024

@terryyin can we fix that?

from lizard.

terryyin avatar terryyin commented on August 17, 2024

from lizard.

nhkrishna5 avatar nhkrishna5 commented on August 17, 2024

Hi @terryyin
How to create the custom file, to override "cyclomatic complexity number". In iOS Swift.

Like mentioned in
-T THRESHOLDS, --Threshold THRESHOLDS
Set the limit for a field. The field can be nloc, cyclomatic_complexity,
token_count, parameter_count, etc. Or an customized file. Lizard will
report warning if a function exceed the limit

from lizard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.