Giter Club home page Giter Club logo

Comments (7)

PhilippSalvisberg avatar PhilippSalvisberg commented on May 26, 2024 1

I do not agree with this rule. My experience is that the default sort option for ASC is widely used and does not lead to problems in understanding the code. Introducing such a rule would lead to a lot of violations, forcing developers to change code without really making it better.

If someone does not have a really good reason for some rule I'd like to reject it.

from plsql-and-sql-coding-guidelines.

S-Koell avatar S-Koell commented on May 26, 2024 1

I would also disagree but I can see an argument for it.
It's similar to specifying the parameter as "IN" in a function/procedure which is regarded as best practice as far as I know. But it is also widely used without.

from plsql-and-sql-coding-guidelines.

S-Koell avatar S-Koell commented on May 26, 2024 1

I'm also for consistency. But my conclusion is different. I suggest to reject this issue and change G-7240 to cover IN OUT mode only.

Sure, that would be the other option. As I said my conclusion was based on "if 7240 exists like it does".

I'm fine with your proposal.

from plsql-and-sql-coding-guidelines.

silviomarghitola avatar silviomarghitola commented on May 26, 2024

from SonarQube

An "ORDER BY" direction should be specified explicitly

ASC or DESC should be specified for every column of an ORDER BY clause to improve readability.

Noncompliant Code Example

BEGIN
  SELECT col1, col2, col3
  BULK COLLECT INTO result
  FROM my_table
  ORDER BY
    col1 ASC,
    col2,
    col3 DESC;
END;

Compliant Solution

BEGIN
  SELECT col1, col2, col3
  BULK COLLECT INTO result
  FROM my_table
  ORDER BY
    col1 ASC,
    col2 ASC,
    col3 DESC;
END;

from plsql-and-sql-coding-guidelines.

PhilippSalvisberg avatar PhilippSalvisberg commented on May 26, 2024

Thanks @S-Koell. You are referring to G-7240 right? I think this guideline is good, but the PL/SQL Cop validator is not consistent. Since it is difficult to determine if a IN OUT parameter is really read & write it just checks if IN or an OUT is defined. This matches the general description of the rule that is better for reader to have explicitly defined the mode (recommendation), but it misses the main issue about unnecessary usage of the combined IN OUT mode. Again, we have to distinguish between the guidelines an the implementation of the validator. Based on that I think it is consistent to reject this new rule.

from plsql-and-sql-coding-guidelines.

S-Koell avatar S-Koell commented on May 26, 2024

@PhilippSalvisberg Yes, I'm talking about G-7240.
First of all: The title of the guideline and the reason don't really match. The title talks about IN OUT but the reason paragraph talks about specifying IN OR OUT.

If the reason paragraph is a valid guideline in your opinion than it perfectly fits in this discussion:
All the arguments for 7240 would apply for this issue:

By showing the mode of parameters, you help the reader. If you do not specify a parameter mode, the default mode is IN.

By showing the ORDER mode you help the reader ....

Explicitly showing the mode indication of all parameters is a more assertive action than simply taking the default mode.

Also applies to ORDER BY

Anyone reviewing the code later will be more confident that you intended the parameter mode to be IN / OUT.

Anyone reviewing will be more confident that you intended ASC / DESC

My conclusion:
For consistency reasons I would be for this rule (if 7240 exists like it does).

You can always deactivate this rule if you don't like it.

Regarding the inconsistencies with 7240:
I think that should be fixed. Maybe two rules:

  • Avoid using an IN OUT parameter as IN or OUT only
  • When specifying parameters always add the parameter mode

from plsql-and-sql-coding-guidelines.

PhilippSalvisberg avatar PhilippSalvisberg commented on May 26, 2024

We discussed on G-7240 on other occasions. I agree we have a consistency issue with G-7240. It really should cover just the combined "IN OUT" mode. The description should be changed and the validator amended. Then, parameters without a mode would not violate a guideline.

I'm also for consistency. But my conclusion is different. I suggest to reject this issue and change G-7240 to cover IN OUT mode only.

from plsql-and-sql-coding-guidelines.

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.