Giter Site home page Giter Site logo

Nested classes issue about radon HOT 3 OPEN

Mahdi-py avatar Mahdi-py commented on June 18, 2024
Nested classes issue

from radon.

Comments (3)

rubik avatar rubik commented on June 18, 2024

Thanks for the bug report @Mahdi-py. Indeed, this is due to the way the AST visitor is implemented. I'll take a look at a possible fix in the near future.

from radon.

Vinno97 avatar Vinno97 commented on June 18, 2024

I noticed the same issue whilst reading the code itself. Am I right assuming that adding visitor.classes_complexity to the following sum would fix this?

radon/radon/visitors.py

Lines 310 to 314 in 44655c8

body_complexity += (
visitor.complexity
+ visitor.functions_complexity
+ len(visitor.functions)
)

Alternatively change

body_complexity += (
    visitor.complexity
    + visitor.functions_complexity
    + len(visitor.functions)
)

to

body_complexity += (
    visitor.total_complexity
    + len(visitor.functions)
)

and change the off property of the visitor to True

from radon.

rubik avatar rubik commented on June 18, 2024

That fix would allow Radon to count the complexity of all the code within the nested classes. That's the correct thing to do. However, it won't cause the nested classes to be shown in the reports. Since we do not report nested functions, I think that's also consistent with the rest of the code. I'll commit this fix after writing some test cases.

from radon.

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.