Giter Club home page Giter Club logo

Comments (6)

macpak avatar macpak commented on August 22, 2024

grabbed

from stylecopanalyzers.

macpak avatar macpak commented on August 22, 2024

This one is a little bit tricky. I checked original StyleCop and for code like:

 int [] a =new int[0];
        var query = from m 

                        in

            a


                    where m > 5


            & m > 2


            group m by m into c


                    select c.Key;

it only reports where m > 5 as an incorrect part of the query. In my opinion it should report more. I'd understand this SA as: each query clause (from, in, where, group, select, let) should be on the same line as the previous line or at the next line. However, doing it this way we completly change the behaviour of this SA. @sharwell , @pdelvo , what do you think about it ?

from stylecopanalyzers.

sharwell avatar sharwell commented on August 22, 2024

The way I interpreted the rule is:

Locate every where, let, group, join, order, and select clause. If the query as a whole spans more than one line, then each of these keywords should appear as the first token on a new line, and there should not be a blank line before it.

I did not include from in this list because it is always the first token of a query, and it may appear at the end of a line containing other tokens which are not part of a query (for example, the var query = part of your sample code). I did not include in because it is part of the from clause, like by is part of the order clause.

For example, the following code, which is your original code without the blank lines, would not produce any SA1102 warnings:

 int [] a =new int[0];
        var query = from m 
                        in
            a
                    where m > 5
            & m > 2
            group m by m into c
                    select c.Key;

from stylecopanalyzers.

macpak avatar macpak commented on August 22, 2024

Ok, so (just curious) you are the author of the original SA ?

from stylecopanalyzers.

sharwell avatar sharwell commented on August 22, 2024

No, I'm actually not even a user of it. 😁

I'm interested in this project primarily for the learning opportunity, although I do want to see it succeed for StyleCop users.

from stylecopanalyzers.

macpak avatar macpak commented on August 22, 2024

Allright. I'll implement it the way you proposed, because it's a very reasonable solution.

from stylecopanalyzers.

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.