Git Product home page Git Product logo

Comments (10)

jeremiah-c-leary avatar jeremiah-c-leary commented on July 3, 2024 1

I have been pondering this for a bit. It looks like indentStyle and indentSize are the only options that are camelCase.

I believe the way forward on this is to change the options to snake case, but also accept the camelCase and throw a warning that it will eventually be deprecated.

I will work on a solution.

--Jeremy

from vhdl-style-guide.

JHertz5 avatar JHertz5 commented on July 3, 2024

@jeremiah-c-leary, I'm happy to raise a PR for this if you're ok with the change.

from vhdl-style-guide.

jeremiah-c-leary avatar jeremiah-c-leary commented on July 3, 2024

Afternoon @JHertz5 ,

I finally pushed my update for this to the issue-1096 branch.

I added a warning if indentSize or indentType is found in any configuration, while also converting them to indent_size and indent_type under the hood.

Let me know what you think.

Regards,

--Jeremy

from vhdl-style-guide.

JHertz5 avatar JHertz5 commented on July 3, 2024

Hi @jeremiah-c-leary. Thanks very much for this! I've given your branch a try and I'm able to trigger the warning that you mentioned, but I'm not sure that the under the hood conversion is working.


With this config:

rule:
  global:
    indent_style: 'smart_tabs'
    indent_size: 3
    # indentStyle: 'smart_tabs'
    # indentSize: 3

I get the following -rc output

$ ./bin/vsg -c ./test.yml -rc constant_001
{
  "rule": {
    "constant_001": {
      "indent_style": "smart_tabs",
      "indent_size": 3,
      "phase": 4,
      "disable": false,
      "fixable": true,
      "severity": "Error"
    }
  }
}

(note that the values of indent_style and indent_size differ from the default) and I see --fix changing files to tab indentation.


However, with this config:

rule:
  global:
    # indent_style: 'smart_tabs'
    # indent_size: 3
    indentStyle: 'smart_tabs'
    indentSize: 3

I get

$ ./bin/vsg -c ./test.yml -rc constant_001
Warning in configuration file ./test.yml: option indentSize will be deprecated in a future release, change to indent_size.
{
  "rule": {
    "constant_001": {
      "indent_style": "spaces",
      "indent_size": 2,
      "phase": 4,
      "disable": false,
      "fixable": true,
      "severity": "Error"
    }
  }
}

(note that the wrning is triggered, but indent_style and indent_size are set to their defaults) and I see --fix changing the previously tabbed file back to space indentation.

Perhaps the deprecated keys are detected and removed from the config in config.py before they get to rule.py where they would be converted?

I also noticed that in the function lBlah in config.py, there is a typo "lDeprectedKeyson line 127 (should belDeprecatedKeys`) which might cause problems.

from vhdl-style-guide.

jeremiah-c-leary avatar jeremiah-c-leary commented on July 3, 2024

Morning @JHertz5 ,

Part of me is thinking changing indentSize and indentStyle to their new values under the hood is the wrong approach. When a rule is deprecated, the user is notified so they can update their configuration. In this case an option has been deprecated, so why do I feel the code must handle this under the hood? I think I should just throw an error and force the user to update. This would keep the code cleaner as the code attempting to convert indentSize and indentStyle would be removed.

Would you have a preference?

--Jeremy

from vhdl-style-guide.

JHertz5 avatar JHertz5 commented on July 3, 2024

Hi @jeremiah-c-leary! I agree, it would definitely be preferable to make a clean transition IMO. The only benefit to the under-the-hood conversion would be that it gives people time to switch over before their configs are broken, but even then, you're just breaking that config later instead of now. If I'm not mistaken, trying to use a deprecated rule throws an error, so it makes sense that using a deprecated config option would do the same.

from vhdl-style-guide.

jeremiah-c-leary avatar jeremiah-c-leary commented on July 3, 2024

Evening @JHertz5 ,

I changed the code to raise an exception if indentSize or indentType is found. The message states to change them to indent_size and indent_type respectively. Could you check it out and let me know what you think of the implementation?

Thanks,

--Jeremy

from vhdl-style-guide.

JHertz5 avatar JHertz5 commented on July 3, 2024

Hi @jeremiah-c-leary. That looks mostly good to me, but I've found a mistake. indentStyle has been renamed to indent_style, but in config.py and in some tests, the code is using indentType as the deprecated name and indent_type as the new name. As a result, using indentStyle doesn't raise the aforementioned error and is silently ignored instead.

from vhdl-style-guide.

jeremiah-c-leary avatar jeremiah-c-leary commented on July 3, 2024

Morning @JHertz5 ,

Good catch. Not sure how I changed indent_style to indent_type.

BTW, it turns out the smart_tab tests were not being executed because the directory was missing __init__.py. I made some changes to include those tests. I discovered this when trying to grep for indentStyle and wondering why the test was not failing.

I pushed an update. Let me know if there are any other issues.

Thanks,

--Jeremy

from vhdl-style-guide.

JHertz5 avatar JHertz5 commented on July 3, 2024

Hi @jeremiah-c-leary. Excellent, thanks very much! I've tested the branch again and it is looking good to me!

from vhdl-style-guide.

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.