MO2k4 / CleanCode

ReSharper/Rider Plugin
MIT License
64 stars 9 forks source link

chained references for linq expression #23

Open sbradl opened 4 years ago

sbradl commented 4 years ago

Probably this is tricky to implement in a general way but I would think of Linq as a fluent API and so it should not count into chained references. At the moment lots of warnings occur in my code because of Linq statements.

MO2k4 commented 4 years ago

That is a good question - should it be only considered for linq expression or also for a fluent api?

There are also open discussions on the original code, regarding this issue:

https://github.com/hhariri/CleanCode/issues/15 https://github.com/hhariri/CleanCode/issues/20

The easiest way for you, would be to increase the setting for "MaximumChainedReferences" to a higher value.

hoolie commented 1 month ago

Linq statements are marked with the PureAttribute.

IMHO a method that is marked as Pure should not be counted as a viaolation of the Law of Demeter and thus be excluded.

The Law of Demeter (LoD) primarily aims to reduce coupling by ensuring that objects only interact with their immediate dependencies. However, LINQ queries, which are fluent in nature and often used to perform complex data transformations in a readable and declarative manner, do not contribute to this kind of tight coupling. Since LINQ operations and other pure functions typically don't violate the encapsulation or modularity that LoD seeks to preserve, they arguably should not be considered violations of LoD.

@MO2k4 What are your thoughts on this? Would this be a good distinction, and do you think it would be feasible to implement?

MO2k4 commented 1 month ago

Hey there

Thanks for your input, but I am not sure if this can be implemented because I think the "pure"ness of a method is just a comment and no attribute to check on

Nevertheless I am very open for pull requests