question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New Importer: IndentationLevelImporter

See original GitHub issue

Feature request

Description

Create an importer that counts the indentation level of each line and generates an cc.json output with attributes like this:

{
    "il1+" : 1,
    "il2+" : 3
}

where il1 is the number of lines in the file with indentation level 1 or higher.

The indentation level is calculated by

(positionOfTheFirstCharacterInLine / tabWidth) + (positionOfTheFirstCharacterInLine % tabWidth == 0 ? 0 : 1)

The tabWidth needs to be estimated before.

The importer should be executable with: ccsh indentationlevelimporter FOLDER/FILE -p PROJECT_NAME -o OUPUT.CC.JSON

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
alexhunzikercommented, Jan 6, 2020

One question, does this generalization conflict with ADR 6: Filters share nothing ?

I would suggest implementing it like the SCMLogParser, in other words all metrics are calculated by the same filter and thus the share nothing principle will not be violated. The potential drawback is, that there may be (too) many command line arguments (… that is if we make the metrics customizable (i.e. max indentation level, predetermined tab width, …). if we just hard-code/guess the parameters as done in the SCMLogParser the interface stays clean. It is a trade-off i guess)

How do we name the importer, as we already have the “SourceCodeParser”, which were an appropriate name for this one as well?

Good question, I asked myself the same and have found no good answer yet.

0reactions
alexhunzikercommented, Jan 6, 2020

@alexhunziker I am not into the code yet, but did think about the option of implementing these new custom metrics into the SourceCodeParser? Would that make sense or is the architecture rather very different?

The architectures are indeed very similar, and a combination technically possible. However I don’t know if this is conceptually desirable, since they do kinda different things; the (sonar) sourceCodeParser gets base metrics for certain languages (currently java only) while this thing here provides some special metrics for any file scanned (that may or may not be meaningful). I don’t know if the use case for this and the (sonar) sourceCodeParser are similar enough to fuse them together. Also the CLI options of a fused importer may get confusing.

Why put it into the SourceCodeParser? @alexhunziker what metrics does the IndendationLevelParser create that the SourceCodeParser also creates? What is actually the same? The ILParser does not have any Sonar and doesn’t it only create indendation level, while the SCParser creates all Sonar metrics + custom nesting level?

The metrics we are obtaining with the new Parser cannot be obtained by Sonar Directly, the only thing it does is computing the maximum nesting level (we created a custom metric for that). It would be possible to generate a custom metric for the sonar plugins that provides the same information as the indentation level parser does, however they would be only applicable to certain programming languages (i.e. Java only at this point)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set Excel import hierarchy with indentation
Set Excel import hierarchy with indentation ... Decide which cells you want to be parent topics, then select the cells below the parent...
Read more >
Evernote importer doesnt recognise bullet list indent levels
I imported notes from evernote. In most of my notes that I checked, all bullet lists indent levels are moved to the first...
Read more >
Tips for New Importers and Exporters
To assist you, we offer the following tips for new importers and ... Fill levels for agricultural quotas and textiles eligible for trade ......
Read more >
PEP 8 – Style Guide for Python Code
Use 4 spaces per indentation level. Continuation lines should align wrapped elements either vertically using Python's implicit line joining ...
Read more >
Problem with indent when i import from excel to project
Hi, I'm trying import my project from excel to MSP but i have a problem with indent. Just when the data is importing,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found