Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Designing For TV: Principles, Patterns And Practical Guidance (Part 2)

      September 5, 2025

      Neo4j introduces new graph architecture that allows operational and analytics workloads to be run together

      September 5, 2025

      Beyond the benchmarks: Understanding the coding personalities of different LLMs

      September 5, 2025

      Top 10 Use Cases of Vibe Coding in Large-Scale Node.js Applications

      September 3, 2025

      Building smarter interactions with MCP elicitation: From clunky tool calls to seamless user experiences

      September 4, 2025

      From Zero to MCP: Simplifying AI Integrations with xmcp

      September 4, 2025

      Distribution Release: Linux Mint 22.2

      September 4, 2025

      Coded Smorgasbord: Basically, a Smorgasbord

      September 4, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Drupal 11’s AI Features: What They Actually Mean for Your Team

      September 5, 2025
      Recent

      Drupal 11’s AI Features: What They Actually Mean for Your Team

      September 5, 2025

      Why Data Governance Matters More Than Ever in 2025?

      September 5, 2025

      Perficient Included in the IDC Market Glance for Digital Business Professional Services, 3Q25

      September 5, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      How DevOps Teams Are Redefining Reliability with NixOS and OSTree-Powered Linux

      September 5, 2025
      Recent

      How DevOps Teams Are Redefining Reliability with NixOS and OSTree-Powered Linux

      September 5, 2025

      Distribution Release: Linux Mint 22.2

      September 4, 2025

      ‘Cronos: The New Dawn’ was by far my favorite experience at Gamescom 2025 — Bloober might have cooked an Xbox / PC horror masterpiece

      September 4, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Adding to the Argument

    CodeSOD: Adding to the Argument

    September 3, 2025

    David G saw a pull request with a surprisingly long thread of comments on it. What was weirder was that the associated ticket was all about adding a single parameter to an existing method. What could be generating that much discussion?

    How could adding an argument add to an argument?

    <span class="hljs-attr">registerFooWrapper</span>: <span class="hljs-keyword">function</span>(<span class="hljs-params">arg1, arg2, arg3, arg4, arg5, arg6, arg7</span>) {
        bar.<span class="hljs-title function_">when</span>(<span class="hljs-string">'bar-event'</span>, <span class="hljs-keyword">function</span>(<span class="hljs-params">context</span>) {
            context.<span class="hljs-title function_">foo</span>({
                <span class="hljs-attr">arg1</span>: arg1,
                <span class="hljs-attr">arg2</span>: arg2,
                <span class="hljs-attr">arg3</span>: arg3,
                <span class="hljs-attr">arg4</span>: arg4,
                <span class="hljs-attr">arg5</span>: arg5,
                <span class="hljs-attr">arg6</span>: arg6,
                <span class="hljs-attr">arg7</span>: arg7,
            });
        });
    }
    

    This is the original version of the JavaScript function. The parameter names have been anonymized. That aside, this still isn’t very good. Seven parameters is likely too many, and based on what I see in setting the context, there is an object type that holds them all, so maybe we should be passing the object around in the first place? Still, this isn’t a WTF by any stretch, and since it’s already deployed code, changing the interface significantly is a bad idea- maybe just adding a parameter is the right choice here. So what generated so much discussion?

    This revision:

    <span class="hljs-attr">registerFooWrapper</span>: <span class="hljs-keyword">function</span>(<span class="hljs-params">arg1, arg2, arg3, arg4, arg5, arg6, arg7, notArg8</span>) {
        <span class="hljs-keyword">if</span> (notArg8 === <span class="hljs-literal">true</span>) {
            bar.<span class="hljs-title function_">when</span>(<span class="hljs-string">'bar-event'</span>, <span class="hljs-keyword">function</span>(<span class="hljs-params">context</span>) {
                context.<span class="hljs-title function_">foo</span>({
                    <span class="hljs-attr">arg1</span>: arg1,
                    <span class="hljs-attr">arg2</span>: arg2,
                    <span class="hljs-attr">arg3</span>: arg3,
                    <span class="hljs-attr">arg4</span>: arg4,
                    <span class="hljs-attr">arg5</span>: arg5,
                    <span class="hljs-attr">arg6</span>: arg6,
                    <span class="hljs-attr">arg7</span>: arg7,
                    <span class="hljs-attr">arg8</span>: !notArg8,
                });
            });
        }
        <span class="hljs-keyword">else</span> {
            bar.<span class="hljs-title function_">when</span>(<span class="hljs-string">'bar-event'</span>, <span class="hljs-keyword">function</span>(<span class="hljs-params">context</span>) {
                context.<span class="hljs-title function_">foo</span>({
                    <span class="hljs-attr">arg1</span>: arg1,
                    <span class="hljs-attr">arg2</span>: arg2,
                    <span class="hljs-attr">arg3</span>: arg3,
                    <span class="hljs-attr">arg4</span>: arg4,
                    <span class="hljs-attr">arg5</span>: arg5,
                    <span class="hljs-attr">arg6</span>: arg6,
                    <span class="hljs-attr">arg7</span>: arg7
                });
            });
        }
    }
    

    Okay, so if notArg8 is true, we pass false to the context. If it’s any other value, we don’t past arg8 at all. I do not understand what I’m looking at here. If the goal is to ensure that arg8 is either true or not set, there are clearer ways to express that idea. But also, the goal of the ticket was not to do that- it was simply to add another parameter, which means you could drop the condition entirely and just add the parameter. context was already receiving arg8 as undefined, so it could clearly handle an undefined value.

    David made some comments on the pull request, but the original developer just ended up going radio silent on it. One of the juniors on David’s team approved it, for some reason, but nobody ever actually hit merge. Instead, a different developer simply made a version that took arg8 as a parameter, passed it down to context, and called it a day. It worked, the tests passed, and everyone was happy.

    Well, except the original developer, but again, who knows what they were trying to do?

    [Advertisement]
    ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleLaracon AU 2025 Talk Titles Revealed
    Next Article 7 Must-Know GSAP Animation Tips for Creative Developers

    Related Posts

    News & Updates

    Building smarter interactions with MCP elicitation: From clunky tool calls to seamless user experiences

    September 4, 2025
    News & Updates

    From Zero to MCP: Simplifying AI Integrations with xmcp

    September 4, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Repurposing Protein Folding Models for Generation with Latent Diffusion

    Repurposing Protein Folding Models for Generation with Latent Diffusion

    Artificial Intelligence

    CVE-2023-50338 – Apache HTTP Server SQL Injection

    Common Vulnerabilities and Exposures (CVEs)

    Rilasciata KDE Gear 25.08: Tutte le Novità e i Miglioramenti per il Tuo Desktop

    Linux

    A tricky, educational quiz: it’s about time..

    Development

    Highlights

    CVE-2025-5401 – Chaitak-Gorai Blogbook SQL Injection

    June 1, 2025

    CVE ID : CVE-2025-5401

    Published : June 1, 2025, 1:15 p.m. | 14 hours, 5 minutes ago

    Description : A vulnerability was found in chaitak-gorai Blogbook up to 92f5cf90f8a7e6566b576fe0952e14e1c6736513. It has been declared as critical. Affected by this vulnerability is an unknown functionality of the file /post.php of the component GET Parameter Handler. The manipulation of the argument p_id leads to sql injection. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. This product takes the approach of rolling releases to provide continious delivery. Therefore, version details for affected and updated releases are not available. The vendor was contacted early about this disclosure but did not respond in any way.

    Severity: 7.3 | HIGH

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    CVE-2025-9589 – Cudy WR1200EA Default Password Disclosure

    August 28, 2025

    First Ubuntu Monthly Snapshot Now Available to Download

    May 29, 2025

    CVE-2025-3626 – Apache Device OS Command Injection

    July 7, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.