Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong line count for the language Elm (and maybe other languages too) when encounter certain characters #568

Open
lucamug opened this issue Feb 20, 2021 · 4 comments

Comments

@lucamug
Copy link

lucamug commented Feb 20, 2021

The following line of Elm code make the counter to stop the count:

    Html.node "style" [] [ Html.text "div[role=button] {-webkit-tap-highlight-color: transparent}" ]

For example, this file 4 lines of code are reported correctly:

module Main exposing (main)

import Html


main =
    Html.node "style" [] [ Html.text "div[role=button] {-webkit-tap-highlight-color: transparent}" ]

But for this file, still 4 lines of code are reported, wrongly.

module Main exposing (main)

import Html


main =
    Html.node "style" [] [ Html.text "div[role=button] {-webkit-tap-highlight-color: transparent}" ]


a =
    3

The culprit seems being {-}, or a similar string where the dash can be followed by any character, like {-xxx}.

@AlDanial
Copy link
Owner

Yes, this is an anticipated bug with roots back to SLOCCount, ref the comment block for function remove_haskell_comments() (which is included as an Elm filter) beginning at

cloc/cloc

Line 7361 in 9b1c380

sub remove_haskell_comments { # {{{1
. It is the {- inside the string that the code doesn't account for. I'll have to add logic to see if comment markers are inside a string.

@lucamug
Copy link
Author

lucamug commented Feb 21, 2021

Take your time. For the moment I just added a space between { and - (that is still valid CSS) 😊

@AlDanial
Copy link
Owner

Well, I did take my time :) I reran the original case reported as showing 3 lines instead of 4. cloc 1.98 reports the answer is 4 although I don't recall actively changing anything for Elm since then. Can you try with the latest cloc?

@includesec-erik
Copy link

@lucamug can you check to see if your original Elm counting edge case still exists with latest cloc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants