konveyor / analyzer-lsp

Add-on that is focused on providing analysis based on the Language Server Protocol.
Apache License 2.0
12 stars 45 forks source link

Our CodeSnips are ugly #241

Open fabianvf opened 1 year ago

fabianvf commented 1 year ago

The gopkg.in/yaml.v2 library is not turning our codesnips into | style multiline strings, it's just leaving them as string literals with \n in there. Ideally we'd output prettier multiline strings because in the current state it's not really human-readable at all.

pranavgaikwad commented 1 year ago

~I think the easiest thing to start with is to have all code snips output as multi-line strings in the output like. Right now, we get mix of multi-line vs inline strings with escaped newlines. Possible solution is to append a newline at the end of codeSnip to force output as above~

EDIT: I learned about this a little more and found out that with the default yaml marshal, this issue cannot be solved without changing the original snip.

fabianvf commented 1 year ago

The issue is as far as I can tell the library doesn't currently have any way to enforce that, if there are certain (undocumented AFAIK) characters in the string it won't use the multi-line syntax

MdSahil-oss commented 1 year ago

@fabianvf @pranavgaikwad I would like to work on this issue.

MdSahil-oss commented 1 year ago

@fabianvf can you please explain how can I reproduce this issue ?

pranavgaikwad commented 1 year ago

@MdSahil-oss In the rule-example.yaml file, lang-ref-001 rule is a good reproducer for this one https://github.com/konveyor/analyzer-lsp/blob/7ebd2f5efb3fbfbb5e102d80e8481ee823fdb3b2/demo-output.yaml#L210

RipulHandoo commented 1 year ago

Hey @fabianvf @pranavgaikwad , I have manually modified the demo-output.yaml And pulled a PR but getting error . How to overcome that, yaml file is valid I double-checked that

RipulHandoo commented 1 year ago

Hey @fabianvf @pranavgaikwad , I have manually modified the demo-output.yaml And pulled a PR but getting error . How to overcome that, yaml file is valid I double-checked that

In this

codeSnip: |
          1  package com.example.apps;
          2  
          3  import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;
          4  
          5  public class App 
          6  {
          7  
          8      public static void main( String[] args )
          9      {
          10          CustomResourceDefinition crd = new CustomResourceDefinition();
          11          System.out.println( crd );
          12  
          13          GenericClass<String> element = new GenericClass<String>(\"Hello world!\");
          14          element.get();
          15      }
          16  }

Do the line number are also have to remove line number and only code lines needs to be in the CodeSnips:

pranavgaikwad commented 1 year ago

@RipulHandoo line numbers are needed

Obasoro commented 1 year ago

@pranavgaikwad is this ticket closed or open elsewhere?