nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: QCoDeS/Qcodes
Pull request #5579 (2023-12-07 10:20:20)

Fix typo in DummyBase::get_idn
fix typo key of dict returned by get_idn of Dummy instruments.


Patch:
diff --git a/docs/changes/newsfragments/underthehood.5579 b/docs/changes/newsfragments/underthehood.5579
new file mode 100644
index 000000000..6c9d14b7c
--- /dev/null
+++ b/docs/changes/newsfragments/underthehood.5579
@@ -0,0 +1,1 @@
+Fix typo: instrument_drivers.mock_instruments.DummyInstrument::get_idn() now returns dict containing key "serial" instead of "seral"
diff --git a/src/qcodes/instrument_drivers/mock_instruments/__init__.py b/src/qcodes/instrument_drivers/mock_instruments/__init__.py
index 89e1a3761..db252c01e 100644
--- a/src/qcodes/instrument_drivers/mock_instruments/__init__.py
+++ b/src/qcodes/instrument_drivers/mock_instruments/__init__.py
@@ -27,7 +27,7 @@ class DummyBase(Instrument):
         return {
             "vendor": "QCoDeS",
             "model": str(self.__class__),
-            "seral": "NA",
+            "serial": "NA",
             "firmware": "NA",
         }
 


Test patch:
diff --git a/tests/test_instrument.py b/tests/test_instrument.py
index 204e79c64..0d15c2d16 100644
--- a/tests/test_instrument.py
+++ b/tests/test_instrument.py
@@ -212,7 +212,7 @@ def test_get_idn(testdummy: DummyInstrument) -> None:
     idn = {
         "vendor": "QCoDeS",
         "model": str(testdummy.__class__),
-        "seral": "NA",
+        "serial": "NA",
         "firmware": "NA",
     }
     assert testdummy.get_idn() == idn
Repository: rwjblue/ember-template-lint
Pull request #129 (2016-11-07 21:41:00)

[Bugfix] Fixes #173
Check if `originalValue` is a String, before spliting it


Patch:
diff --git a/lib/rules/deprecations/lint-deprecated-inline-view-helper.js b/lib/rules/deprecations/lint-deprecated-inline-view-helper.js
index f1968ec..52f7279 100644
--- a/lib/rules/deprecations/lint-deprecated-inline-view-helper.js
+++ b/lib/rules/deprecations/lint-deprecated-inline-view-helper.js
@@ -39,7 +39,7 @@ function manageMustacheViewInvocation(context, node, isBlockStatement) {
       var currentPair = pairs[i];
       var originalValue = currentPair.value.original;
 
-      if (originalValue.split('.')[0] == 'view') {
+      if (typeof originalValue === 'string' && originalValue.split('.')[0] == 'view') {
         if (isBlockStatement) {
           context.processInBlockStatement(node, currentPair);
         } else {
@@ -65,7 +65,7 @@ module.exports = function(addonContext) {
           if (value.type === 'MustacheStatement') {
             var originalValue = value.path.original;
 
-            if (originalValue.split('.')[0] == 'view') {
+            if (typeof originalValue === 'string' && originalValue.split('.')[0] == 'view') {
               this.processAsElementAttribute(node, currentAttribute);
             }
           }


Test patch:
diff --git a/test/unit/rules/deprecations/lint-deprecated-inline-view-helper-test.js b/test/unit/rules/deprecations/lint-deprecated-inline-view-helper-test.js
index c1e6ad7..ad45cc9 100644
--- a/test/unit/rules/deprecations/lint-deprecated-inline-view-helper-test.js
+++ b/test/unit/rules/deprecations/lint-deprecated-inline-view-helper-test.js
@@ -12,9 +12,9 @@ generateRuleTests({
   config: true,
 
   good: [
-    {
-      template: '{{great-fishsticks}}'
-    }
+    '{{great-fishsticks}}',
+    '{{input placeholder=(t "email") value=email}}',
+    '{{title "CrossCheck Web" prepend=true separator=" | "}}'
   ],
 
   bad: [
Repository: rwjblue/ember-template-lint
Pull request #140 (2016-11-17 08:04:08)

Enable empty alt attributes for img-alt-attributes test
See https://github.com/rwjblue/ember-cli-template-lint/issues/174

I really like the new "img-alt-attributes" rule. However, it currently also fails on e.g. `<img src='...' alt=''>`, 
which is valid. Consider this use case for icons:

```html
<a href='users.html'>
  <img src='users.png' alt=''>
  Users
</a>
```

An empty alt tag has a distinctively different semantic meaning from a missing alt tag - an image with an empty alt tag will simply be ignored by screen readers, while an image with a missing alt tag will have its file name read (or something like this). In the above use case, by adding an alt tag "users" to the icon, a screen reader would read out "Users Users", which wouldn't be helpful at all. Further information on the topic can be found here: https://www.w3.org/TR/WCAG20-TECHS/H67.html

Considering this, the rule should allow empty alt tags and only error on missing ones.


Patch:
diff --git a/lib/rules/lint-img-alt-attributes.js b/lib/rules/lint-img-alt-attributes.js
index 22658bf..ef974f2 100644
--- a/lib/rules/lint-img-alt-attributes.js
+++ b/lib/rules/lint-img-alt-attributes.js
@@ -49,13 +49,5 @@ module.exports = function(addonContext) {
 function isAltPresent(node) {
   var altAttribute = AstNodeInfo.findAttribute(node, 'alt');
 
-  if (!altAttribute) { return false; }
-
-  switch (altAttribute.value.type) {
-  case 'TextNode':
-    return altAttribute.value.chars.length > 0;
-  case 'ConcatStatement':
-  case 'MustacheStatement':
-    return true;
-  }
+  return !!altAttribute;
 }


Test patch:
diff --git a/test/unit/rules/lint-img-alt-attributes-test.js b/test/unit/rules/lint-img-alt-attributes-test.js
index eaa810b..bba6015 100644
--- a/test/unit/rules/lint-img-alt-attributes-test.js
+++ b/test/unit/rules/lint-img-alt-attributes-test.js
@@ -11,7 +11,9 @@ generateRuleTests({
     '<img alt="hullo">',
     '<img alt={{foo}}>',
     '<img alt="blah {{derp}}">',
-    '<img aria-hidden="true">'
+    '<img aria-hidden="true">',
+    '<img alt="">',
+    '<img alt>'
   ],
 
   bad: [
@@ -26,30 +28,6 @@ generateRuleTests({
         line: 1,
         column: 0
       }
-    },
-    {
-      template: '<img alt>',
-
-      result: {
-        rule: 'img-alt-attributes',
-        message: 'img tags must have an alt attribute',
-        moduleId: 'layout.hbs',
-        source: '<img alt>',
-        line: 1,
-        column: 0
-      }
-    },
-    {
-      template: '<img alt="">',
-
-      result: {
-        rule: 'img-alt-attributes',
-        message: 'img tags must have an alt attribute',
-        moduleId: 'layout.hbs',
-        source: '<img alt="">',
-        line: 1,
-        column: 0
-      }
     }
   ]
 });
Repository: rwjblue/ember-template-lint
Pull request #143 (2016-11-17 21:54:12)

Make rel=noreferrer satisfy link-rel-noopener
…as per http://github.com/rwjblue/ember-template-lint/issues/139


Patch:
diff --git a/README.md b/README.md
index 0696540..9fb76a5 100644
--- a/README.md
+++ b/README.md
@@ -326,7 +326,7 @@ However, this practice has performance problems (see [https://jakearchibald.com/
 and also opens a door to some security attacks because the opened page can redirect the opener app
 to a malicious clone to perform phishing on your users.
 Adding `rel="noopener"` closes that door and avoids javascript in the opened tab to block the main
-thread in the opener.
+thread in the opener. Also note that adding `rel="noreferrer"` will [acheive the same goal](https://html.spec.whatwg.org/multipage/semantics.html#link-type-noreferrer).
 
 This rule forbids the following:
 
diff --git a/lib/rules/lint-link-rel-noopener.js b/lib/rules/lint-link-rel-noopener.js
index fb4fe8e..4e3eaea 100644
--- a/lib/rules/lint-link-rel-noopener.js
+++ b/lib/rules/lint-link-rel-noopener.js
@@ -65,8 +65,8 @@ function hasRelNoopener(node) {
 
   switch (relAttribute.value.type) {
   case 'TextNode':
-    return relAttribute.value.chars.indexOf('noopener') !== -1;
+    return /no(opener|referrer)/.test(relAttribute.value.chars);
   default:
     return false;
   }
-}
\ No newline at end of file
+}


Test patch:
diff --git a/test/unit/rules/lint-link-rel-noopener-test.js b/test/unit/rules/lint-link-rel-noopener-test.js
index 63840c3..d186e29 100644
--- a/test/unit/rules/lint-link-rel-noopener-test.js
+++ b/test/unit/rules/lint-link-rel-noopener-test.js
@@ -11,7 +11,8 @@ generateRuleTests({
     '<a href="/some/where"></a>',
     '<a href="/some/where" target="_self"></a>',
     '<a href="/some/where" target="_blank" rel="noopener"></a>',
-    '<a href="/some/where" target="_blank" rel="noopener noreferrer"></a>'
+    '<a href="/some/where" target="_blank" rel="noopener noreferrer"></a>',
+    '<a href="/some/where" target="_blank" rel="noreferrer"></a>'
   ],
 
   bad: [
Repository: rwjblue/ember-template-lint
Pull request #205 (2017-05-11 21:54:51)

invalid-interactive: allow form elements to have onsubmit attributes
The rule allows `<form {{action "foo" on="submit"}}>` but not `<form onsubmit={{action "foo"}}>`. Now it allows both.

rwjblue: Looks like I just created a merge conflict for you here, would you mind updating?

Patch:
diff --git a/lib/rules/lint-invalid-interactive.js b/lib/rules/lint-invalid-interactive.js
index cb8f36b..1680603 100644
--- a/lib/rules/lint-invalid-interactive.js
+++ b/lib/rules/lint-invalid-interactive.js
@@ -66,6 +66,11 @@ module.exports = class InvalidInteractive extends Rule {
         let helperName = node.value.path.original;
 
         if (helperName === 'action') {
+          // Allow onsubmit={{action "foo"}} on form tags
+          if (this._element.tag === 'form' && node.name === 'onsubmit') {
+            return;
+          }
+
           this.log({
             message: 'Interaction added to non-interactive element',
             line: node.loc && node.loc.start.line,


Test patch:
diff --git a/test/unit/rules/lint-invalid-interactive-test.js b/test/unit/rules/lint-invalid-interactive-test.js
index 7ff1209..a9970b8 100644
--- a/test/unit/rules/lint-invalid-interactive-test.js
+++ b/test/unit/rules/lint-invalid-interactive-test.js
@@ -12,6 +12,7 @@ generateRuleTests({
     '<div role="button" {{action "foo"}}></div>',
     '<li><button {{action "foo"}}></button></li>',
     '<form {{action "foo" on="submit"}}></form>',
+    '<form onsubmit={{action "foo"}}></form>',
     {
       config: { additionalInteractiveTags: ['div'] },
       template: '<div {{action "foo"}}></div>'
@@ -45,6 +46,17 @@ generateRuleTests({
       }
     },
 
+    {
+      template: '<div onsubmit={{action "foo"}}></div>',
+
+      result: {
+        message: 'Interaction added to non-interactive element',
+        line: 1,
+        column: 5,
+        source: '<div onsubmit={{action \"foo\"}}></div>'
+      }
+    },
+
     {
       template: '<form {{action "foo" on="click"}}></form>',
Repository: rwjblue/ember-template-lint
Pull request #216 (2017-06-12 14:41:02)

Added "byte order mark" test
Added failing test to unit test suite for block-indentation rule. The test input starts with a "byte order mark".

See issue #215


Patch:
diff --git a/lib/index.js b/lib/index.js
index a4e1835..563df33 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -2,6 +2,7 @@
 
 const precompile = require('glimmer-engine').precompile;
 const getConfig = require('./get-config');
+const stripBom = require('strip-bom');
 
 const WARNING_SEVERITY = 1;
 const ERROR_SEVERITY = 2;
@@ -93,9 +94,9 @@ class Linter {
     };
 
     try {
-      precompile(options.source, {
+      precompile(stripBom(options.source), {
         moduleName: options.moduleId,
-        rawSource: options.source,
+        rawSource: stripBom(options.source),
         plugins: {
           ast: this.buildASTPlugins(pluginConfig)
         }
diff --git a/package.json b/package.json
index ebfa370..99857cc 100644
--- a/package.json
+++ b/package.json
@@ -36,6 +36,7 @@
     "mocha-eslint": "^2.0.2",
     "mocha-only-detector": "^0.1.0",
     "rimraf": "^2.5.2",
+    "strip-bom": "^3.0.0",
     "testem": "^1.7.0"
   },
   "engines": {


Test patch:
diff --git a/test/unit/rules/lint-block-indentation-test.js b/test/unit/rules/lint-block-indentation-test.js
index 53172c4..66620dd 100644
--- a/test/unit/rules/lint-block-indentation-test.js
+++ b/test/unit/rules/lint-block-indentation-test.js
@@ -179,7 +179,12 @@ generateRuleTests({
         '  <!-- foo bar baz -->',
         '</div>'
       ].join('\n')
-    }
+    },
+    [
+      '\uFEFF{{#if foo}}',
+      '  <div></div>',
+      '{{/if}}'
+    ].join('\n')
   ],
 
   bad: [
@@ -504,6 +509,21 @@ generateRuleTests({
         line: 1,
         column: 6
       }
+    },
+    {
+      template: [
+        '\uFEFF {{#if foo}}',
+        '{{/if}}'
+      ].join('\n'),
+
+      result: {
+        rule: 'block-indentation',
+        message: 'Incorrect indentation for `if` beginning at L1:C1. Expected `{{/if}}` ending at L2:C7 to be at an indentation of 1 but was found at 0.',
+        moduleId: 'layout.hbs',
+        source: '{{#if foo}}\n{{/if}}',
+        line: 2,
+        column: 7
+      }
     }
   ]
 });
Repository: rwjblue/ember-template-lint
Pull request #233 (2017-06-28 12:04:55)

Issue 232 bare strings with concat statement
This PR suggests a fix for #232.


Patch:
diff --git a/lib/rules/lint-bare-strings.js b/lib/rules/lint-bare-strings.js
index cd10384..23948b6 100644
--- a/lib/rules/lint-bare-strings.js
+++ b/lib/rules/lint-bare-strings.js
@@ -159,15 +159,22 @@ module.exports = class LogStaticStrings extends Rule {
   }
 
   _checkNodeAndLog(node, additionalDescription, loc) {
-    let bareStringText = this._getBareString(node.chars);
-
-    if (bareStringText) {
-      this.log({
-        message: `Non-translated string used${additionalDescription}`,
-        line: loc.start.line,
-        column: loc.start.column,
-        source: bareStringText
-      });
+    if (node.type === 'TextNode') {
+      let bareStringText = this._getBareString(node.chars);
+
+      if (bareStringText) {
+        this.log({
+          message: `Non-translated string used${additionalDescription}`,
+          line: loc.start.line,
+          column: loc.start.column,
+          source: bareStringText
+        });
+      }
+    } else if (node.type === 'ConcatStatement') {
+      for (let i = 0; i < node.parts.length; i++) {
+        let subNode = node.parts[i];
+        this._checkNodeAndLog(subNode, additionalDescription, loc);
+      }
     }
   }
 };


Test patch:
diff --git a/test/unit/rules/lint-bare-strings-test.js b/test/unit/rules/lint-bare-strings-test.js
index 9406a0d..2094f74 100644
--- a/test/unit/rules/lint-bare-strings-test.js
+++ b/test/unit/rules/lint-bare-strings-test.js
@@ -67,7 +67,13 @@ generateRuleTests({
       template: '<input placeholder="hahaha">'
     },
 
-    '<foo-bar>\n</foo-bar>'
+    '<foo-bar>\n</foo-bar>',
+
+    {
+      // combine bare string with a variable
+      config: ['X'],
+      template: '<input placeholder="{{foo}}X">'
+    }
   ],
 
   bad: [
@@ -122,6 +128,19 @@ generateRuleTests({
       }
     },
 
+    {
+      template: '<input placeholder="{{foo}}hahaha trolol">',
+
+      result: {
+        rule: 'bare-strings',
+        moduleId: 'layout.hbs',
+        message: 'Non-translated string used in `placeholder` attribute',
+        line: 1,
+        column: 7,
+        source: 'hahaha trolol'
+      }
+    },
+
     {
       config: { globalAttributes: ['data-foo'] },
       template: '<div data-foo="derpy"></div>',
Repository: rwjblue/ember-template-lint
Pull request #250 (2017-07-31 19:05:21)

Fix empty errors
Hi @rwjblue 
This PR should fix an issue related to formatting empty errors.
The bug has been noticed in: https://github.com/rwjblue/ember-cli-template-lint/issues/273


Patch:
diff --git a/lib/index.js b/lib/index.js
index 5c09d07..ac9613b 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -149,33 +149,41 @@ class Linter {
   }
 
   static errorsToMessages(filePath, errors, options) {
-    options = options || {};
+    errors = errors || [];
+    options = options || {
+      verbose: false
+    };
+
+    if (errors.length === 0) {
+      return '';
+    }
+
+    let errorsMessages = errors.map((error) => this._formatError(error, options)).join('\n');
 
+    return `${chalk.underline(filePath)}\n${errorsMessages}\n`;
+  }
+
+  static _formatError(error, options) {
+    let message = '';
     let severities = {
       1: 'warrning',
       2: 'error'
     };
 
-    let errorsMessages = errors.map(error => {
-      let message = '';
-
-      if (error.line && error.column) {
-        message += chalk.dim(`  ${error.line}:${error.column}`);
-      } else {
-        message += chalk.dim('  -:-');
-      }
+    if (error.line && error.column) {
+      message += chalk.dim(`  ${error.line}:${error.column}`);
+    } else {
+      message += chalk.dim('  -:-');
+    }
 
-      message += `  ${chalk.red(severities[error.severity] || 'error')}`;
-      message += `  ${error.message}  ${chalk.dim(error.rule)}`;
+    message += `  ${chalk.red(severities[error.severity] || 'error')}`;
+    message += `  ${error.message}  ${chalk.dim(error.rule)}`;
 
-      if (options.verbose) {
-        message += `\n${error.source}`;
-      }
-
-      return message;
-    }).join('\n');
+    if (options.verbose) {
+      message += `\n${error.source}`;
+    }
 
-    return `${chalk.underline(filePath)}\n${errorsMessages}\n`;
+    return message;
   }
 }
 


Test patch:
diff --git a/test/acceptance-test.js b/test/acceptance-test.js
index c4ec422..9ccdc63 100644
--- a/test/acceptance-test.js
+++ b/test/acceptance-test.js
@@ -568,5 +568,11 @@ describe('public api', function() {
         '  -:-  error  some message2  some rule2\n'
       );
     });
+
+    it('formats empty errors', function() {
+      let result = Linter.errorsToMessages('file/path', []);
+
+      expect(result).to.equal('');
+    });
   });
 });
Repository: rwjblue/ember-template-lint
Pull request #268 (2017-09-14 17:50:37)

rule lint-simple-unless throws an error when template contains an emp…
…ty inverse block

/template.hbs
  -:-  error  Cannot read property 'path' of undefined  undefined


Patch:
diff --git a/lib/rules/lint-simple-unless.js b/lib/rules/lint-simple-unless.js
index db6ae55..57301db 100644
--- a/lib/rules/lint-simple-unless.js
+++ b/lib/rules/lint-simple-unless.js
@@ -28,7 +28,7 @@ module.exports = class LintSimpleUnless extends Rule {
             } else {
               this._followingElseBlock(node);
             }
-          } else if (nodePathOriginal === 'if') {
+          } else if (nodePathOriginal === 'if' && nodeInverse.body[0]) {
             if (nodeInverse.body[0].path && nodeInverse.body[0].path.original  === 'unless') {
               this._asElseUnlessBlock(node);
             }


Test patch:
diff --git a/test/unit/rules/lint-simple-unless-test.js b/test/unit/rules/lint-simple-unless-test.js
index 8c75929..7458534 100644
--- a/test/unit/rules/lint-simple-unless-test.js
+++ b/test/unit/rules/lint-simple-unless-test.js
@@ -12,6 +12,7 @@ generateRuleTests({
     '<div class="{{unless foo \'no-foo\'}}"></div>',
     '<div class="{{if foo \'foo\'}}"></div>',
     '{{unrelated-mustache-without-params}}',
+    '{{#if foo}}{{else}}{{/if}}',
     [
       '{{#unless hamburger}}',
       '  HOT DOG!',
Repository: gitleaks/gitleaks
Pull request #1767 (2025-02-21 20:45:34)

Make AddFinding public
### Description:

To allow other tools using d.Detect() to leverage the code in AddFinding

Changes:

- Rename d.addFinding -> d.AddFinding
- Add d.Findings()

My use case: https://github.com/leaktk/scanner/pull/107/files#diff-f8472fe0bafccc33f268c74d1bd2a697594914d4e1d796805b254249cbc78828R175-R182

### Checklist:

* [x] Does your PR pass tests?
* [ ] ~Have you written new tests for your changes?~ (N/A)
* [x] Have you lint your code locally prior to submission?

cc: @zricethezav && @rgmz 



Patch:
diff --git a/detect/detect.go b/detect/detect.go
index f2990d9..8bc418f 100644
--- a/detect/detect.go
+++ b/detect/detect.go
@@ -568,8 +568,8 @@ func allTrue(bools []bool) bool {
 	return allMatch
 }
 
-// addFinding synchronously adds a finding to the findings slice
-func (d *Detector) addFinding(finding report.Finding) {
+// AddFinding synchronously adds a finding to the findings slice
+func (d *Detector) AddFinding(finding report.Finding) {
 	globalFingerprint := fmt.Sprintf("%s:%s:%d", finding.File, finding.RuleID, finding.StartLine)
 	if finding.Commit != "" {
 		finding.Fingerprint = fmt.Sprintf("%s:%s:%s:%d", finding.Commit, finding.File, finding.RuleID, finding.StartLine)
@@ -609,7 +609,12 @@ func (d *Detector) addFinding(finding report.Finding) {
 	d.findingMutex.Unlock()
 }
 
-// addCommit synchronously adds a commit to the commit slice
+// Findings returns the findings added to the detector
+func (d *Detector) Findings() []report.Finding {
+	return d.findings
+}
+
+// AddCommit synchronously adds a commit to the commit slice
 func (d *Detector) addCommit(commit string) {
 	d.commitMap[commit] = true
 }
diff --git a/detect/directory.go b/detect/directory.go
index cd9d9f4..7beb5e6 100644
--- a/detect/directory.go
+++ b/detect/directory.go
@@ -102,7 +102,7 @@ func (d *Detector) DetectFiles(paths <-chan sources.ScanTarget) ([]report.Findin
 						// need to add 1 since line counting starts at 1
 						finding.StartLine += (totalLines - linesInChunk) + 1
 						finding.EndLine += (totalLines - linesInChunk) + 1
-						d.addFinding(finding)
+						d.AddFinding(finding)
 					}
 				}
 
diff --git a/detect/git.go b/detect/git.go
index b1347de..89ae140 100644
--- a/detect/git.go
+++ b/detect/git.go
@@ -62,7 +62,7 @@ func (d *Detector) DetectGit(cmd *sources.GitCmd, remote *RemoteInfo) ([]report.
 					}
 
 					for _, finding := range d.Detect(fragment) {
-						d.addFinding(augmentGitFinding(remote, finding, textFragment, gitdiffFile))
+						d.AddFinding(augmentGitFinding(remote, finding, textFragment, gitdiffFile))
 					}
 				}
 				return nil


Test patch:
diff --git a/detect/baseline_test.go b/detect/baseline_test.go
index 6eca4e6..1d6e59b 100644
--- a/detect/baseline_test.go
+++ b/detect/baseline_test.go
@@ -133,7 +133,7 @@ func TestIgnoreIssuesInBaseline(t *testing.T) {
 		require.NoError(t, err)
 		d.baseline = test.baseline
 		for _, finding := range test.findings {
-			d.addFinding(finding)
+			d.AddFinding(finding)
 		}
 		assert.Len(t, d.findings, test.expectCount)
 	}