Menu

duplInheritedMember false positive with mixed static and runtime functions

2024-05-24
2024-05-27
  • Steve Albright

    Steve Albright - 2024-05-24

    static functions are confusing duplInheritedMember

    warning: duplInheritedMember - The class 'TheClass' defines member function with name 'CreateLabel' also defined in its parent class 'TheParent'.

    class TheParent
    {
    protected:
       static QObject* CreateLabel();
    };
    
    class TheClass : public TheParent
    {
    private:
          QObject* CreateLabel();
    };
    
     
  • CHR

    CHR - 2024-05-25

    Having two functions with the same name can lead to mixups and confusion. Making one of them static doesn't prevent that.

     
    • Steve Albright

      Steve Albright - 2024-05-27

      I don't totally disagree however you can have private functions with the same name and they don't conflict. Here we have functions that are intended to be called differently, one with a class, one without so it kind of seems like calling out the conflict isn't useful.

      We only have this a few times in our very large code base, I have suppressed them but would rather not and would rather not rename either - the intent is the same and they are used differently.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.