florianschanda / miss_hit

MATLAB Independent, Small & Safe, High Integrity Tools - code formatter and more
GNU General Public License v3.0
158 stars 21 forks source link

Method naming applied to setters and getters leads to false positives #287

Open pvogt09 opened 3 months ago

pvogt09 commented 3 months ago

MISS_HIT Component affected Please choose one from:

Your MATLAB/Octave environment

Your operating system and Python version

Describe the bug Running the style checker on

classdef Setter < handle
    properties (SetAccess = private)
        Attribute
    end

    methods

        function set.Attribute(this, attribute)
            this.Attribute = attribute;
        end

    end
end

results in a style violation

In Setter.m, line 8
|        function set.Attribute(this, attribute)
|                      ^^^^^^^^^^style: violates naming scheme for method [naming_functions]

being reported when using a default settings that should not be reported because there are no style restrictions on attributes imposed. set.* and get.* methods have to contain the name of the attribute to work at all, so they should be treated differently compared to normal methods. Maybe a special naming scheme parameter for class attributes could be introduced to take this into account or the part after the dot could be checked against the names of the attributes the class has (although this might not work well with inheritance in case the parent class is not available).