puml2code icon indicating copy to clipboard operation
puml2code copied to clipboard

No class names generated?

Open Bambofy opened this issue 3 years ago • 11 comments

##Description When running the tool, the output code is incomplete, missing the class name.

  • Type: Bug

Bug

debian 10 64bit. node version v10.21.0 version 0.1.0

.puml file:

@startuml

class Test

@enduml

puml2code command: puml2code -i class_diagram.puml -o ./src/ -l cpp

puml2code output

Handlebars: Access has been denied to resolve the property "getFullName" because it is not an "own property" of its parent. You can add a runtime option to disable the check or this warning: See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details Handlebars: Access has been denied to resolve the property "getExtends" because it is not an "own property" of its parent. You can add a runtime option to disable the check or this warning: See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details Handlebars: Access has been denied to resolve the property "getPrivateFields" because it is not an "own property" of its parent. You can add a runtime option to disable the check or this warning: See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details Handlebars: Access has been denied to resolve the property "getFields" because it is not an "own property" of its parent. You can add a runtime option to disable the check or this warning: See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details Handlebars: Access has been denied to resolve the property "getConstructorArgs" because it is not an "own property" of its parent. You can add a runtime option to disable the check or this warning: See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details Handlebars: Access has been denied to resolve the property "getMethods" because it is not an "own property" of its parent. You can add a runtime option to disable the check or this warning: See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details

C++ code output 'Test.h':

/**
 * \file .h
 */

#ifndef _h
#define _h




class  {
  private:
  protected:
  public:

  public:
    ()
    {
      // @todo
    }
    // Public methods


  // Protected methods
  protected:

  // Private methods
  private:
}

#endif // _h

Bambofy avatar Jul 27 '20 20:07 Bambofy

Looks a clear bug. probably there is no proper handling when class definition is empy. What happens if you add more content to class? Does example work for you? I’m on holiday so fix is coming a bit later. PR is also welcome :)

jupe avatar Jul 28 '20 04:07 jupe

Ok thanks!

If i try the example this is the output (it doesn't save to a file):

Handlebars: Access has been denied to resolve the property "getFullName" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "getExtends" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "getPrivateFields" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "getFields" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "getConstructorArgs" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "getMethods" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details

/**
 * \file .h
 */

#ifndef _h
#define _h




class  {
  private:
  protected:
  public:

  public:
    ()
    {
      // @todo
    }
    // Public methods


  // Protected methods
  protected:

  // Private methods
  private:
}

#endif // _h

/**
 * \file .h
 */

#ifndef _h
#define _h




class  {
  private:
  protected:
  public:

  public:
    ()
    {
      // @todo
    }
    // Public methods


  // Protected methods
  protected:

  // Private methods
  private:
}

#endif // _h

/**
 * \file .h
 */

#ifndef _h
#define _h




class  {
  private:
  protected:
  public:

  public:
    ()
    {
      // @todo
    }
    // Public methods


  // Protected methods
  protected:

  // Private methods
  private:
}

#endif // _h

Bambofy avatar Jul 28 '20 08:07 Bambofy

Just tested on my macbook, it doesn't work here their, exactly the same results, device details:

Catalina 10.15.6 Node version: 12.18.1

Bambofy avatar Jul 28 '20 11:07 Bambofy

Works on my PC 64bit win10 Node v10.15.2

Bambofy avatar Jul 28 '20 12:07 Bambofy

so it didn’t work with node v12 but works with node v10 ? I don’t think that OS causes this..

jupe avatar Jul 29 '20 19:07 jupe

note that CI doesn’t validate currently node v12.. have to add it there as well

jupe avatar Jul 29 '20 19:07 jupe

I was not able to reproduce this issue yet with any node version. I added also node v12 to CI and same puml file you mention without luck. output looks correct to me: https://app.circleci.com/pipelines/github/jupe/puml2code/255/workflows/8573a73d-1c03-41a3-86ea-38bc13f2d4ea/jobs/778

/**
 * \file Test.h
 */

#ifndef Test_h
#define Test_h




class Test {
  private:
  protected:
  public:

  public:
    Test()
    {
      // @todo
    }
    // Public methods


  // Protected methods
  protected:

  // Private methods
  private:
}

#endif // Test_h

Tried also with Mac. CI are running with linux. How did you install tool ? via npm or git clone.. ?

jupe avatar Jul 30 '20 06:07 jupe

I was not able to reproduce this issue yet with any node version. I added also node v12 to CI and same puml file you mention without luck. output looks correct to me: https://app.circleci.com/pipelines/github/jupe/puml2code/255/workflows/8573a73d-1c03-41a3-86ea-38bc13f2d4ea/jobs/778

/**
 * \file Test.h
 */

#ifndef Test_h
#define Test_h




class Test {
  private:
  protected:
  public:

  public:
    Test()
    {
      // @todo
    }
    // Public methods


  // Protected methods
  protected:

  // Private methods
  private:
}

#endif // Test_h

Tried also with Mac. CI are running with linux. How did you install tool ? via npm or git clone.. ?

I installed puml2code by git cloning the repository and then npm -i -g within the directory

Bambofy avatar Jul 30 '20 07:07 Bambofy

I have setup the puml2code project on my macbook, it runs correctly when ran in the development environment (VS Code). It must be something to do with the installation commands.

edit 1: It looks like this is a security feature of Handlebars see: https://stackoverflow.com/a/61346190/1322654

edit 2: In the package.json file, Handlebars is set to ^4.1.1 which means the latest handlebars is being installed, this is probably why it installs 4.6.0/latest handlebars instead of 4.1.1

edit 3: I think that at (https://github.com/jupe/puml2code/blob/master/src/index.js#L144) this line, you need to supply the template with template({element: element}) to fix the security error but i'm not certain, this change will mean you have to add prefixes to the handlebar templates

Bambofy avatar Jul 31 '20 09:07 Bambofy

@Bambofy thanks for investigation help. Unfortunately I haven’t had time to test this more but thanks for you, I’ve now idea’s what to try next..

jupe avatar May 09 '21 04:05 jupe

For me it gives the exact same error "Handlebars: Access has been denied" on 2 separate environments. The first one:

OS: Windows 11
Node: v16.13.2
NPM: v8.1.2
puml2code: v0.7.0

The second one:

OS: Ubuntu 20
Node: v14.18.3
NPM: v8.3.2
puml2code: v0.7.0

I also tried installing it with npm -g install puml2code and by cloning the repo but the result is exactly the same.

cTatu avatar Apr 06 '22 10:04 cTatu