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

Feature request - Include code in strings #382

Open
8483 opened this issue Mar 21, 2023 · 3 comments
Open

Feature request - Include code in strings #382

8483 opened this issue Mar 21, 2023 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@8483
Copy link

8483 commented Mar 21, 2023

I tried scc on my project and I like what it outputs.

What I've noticed is that it gives me 90 SQL lines (those in .sql files), while the app has almost the same amount of SQL (in strings) as Javascript.

───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
Svelte                      66     14314     2247       601    11466        520
JavaScript                  43     12968     1898       799    10271        409
SQL                          8        90       20         2       68          0
Shell                        8        73       13        13       47         17
JSON                         7      5005        0         0     5005          0
CSS                          1       477       99        55      323          0
HTML                         1        34        9         0       25          0
Markdown                     1         0        0         0        0          0
gitignore                    1        15        3         3        9          0
───────────────────────────────────────────────────────────────────────────────
Total                      136     32976     4289      1473    27214        946
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop (organic) $867,216
Estimated Schedule Effort (organic) 13.03 months
Estimated People Required (organic) 5.91
───────────────────────────────────────────────────────────────────────────────
Processed 1182819 bytes, 1.183 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────

Here's an example of the SQL code I am talking about...

const express = require("express");
const router = express.Router();

router.get("/api/categories", async (req, res, next) => {
    try {
        let request = req.app.locals.pool.request();

        let query = `
            select 
                cast(acClassif as nvarchar(255)) categoryKey,
                cast(acName as nvarchar(255)) categoryName
            from tHE_SetItemCateg 
            where acType = 'P'
        `;

        let result = await request.query(query);

        let final = result.recordset;

        res.send(final);
    } catch (err) {
        next(err);
    }
});

module.exports = router;

The SQL in the string is not counted at all.

This is probably impossible to pull off, I just wanted to point it out.

It could be made easier if we declare the language used. Ex.

let query = /*sql*/ `
    -- sql
    select 
        cast(acClassif as nvarchar(255)) categoryKey,
        cast(acName as nvarchar(255)) categoryName
    from tHE_SetItemCateg 
    where acType = 'P'
`;
@boyter
Copy link
Owner

boyter commented Mar 21, 2023

Thanks.

So... this is possible to do, and I think tokei does to an extent for things like markdown files by looking for the embedding as you have in the above.

I know tools like intellij can do this, so perhaps whatever technique they use (they do parse the code but that shouldn't give sql information) might be something to copy. Something to investigate there.

Not saying no to this, just not sure how to go about doing it yet.

@boyter boyter added enhancement New feature or request help wanted Extra attention is needed labels Mar 21, 2023
@8483
Copy link
Author

8483 commented Mar 21, 2023

Thank you for the reply.

My naive approach would be to "tag" the string with a comment, and count the lines inside the quotes, as if they were regular lines in a regular file. The same logic used for the files can be applied to the string text.

I really appreciate and am grateful for the existing features, and this was just something I wanted to mention, if you felt bored xD.

Thanks again.

@boyter
Copy link
Owner

boyter commented Mar 22, 2023

Hah bored... sometimes. What I really want to do is bring in the changes I have been working on to have correct .gitignore support. Soon. Then I can get some other bugs sorted out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants