PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: vaskoz/dailycodingproblem-go (go)
Issue: Day 111
Good morning! Here's your coding interview problem for today.

This problem was asked by Google.

Given a word W and a string S, find all starting indices in S which are anagrams of W.

For example, given that W is "ab", and S is "abxaba", return 0, 3, and 4.
Pull request description: Day111
Resolves #232.

Patch:
diff --git a/README.md b/README.md
index fc05bc0..a0e3c20 100644
--- a/README.md
+++ b/README.md
@@ -119,3 +119,4 @@ problems from
 * [Day 107](https://github.com/vaskoz/dailycodingproblem-go/issues/225)
 * [Day 108](https://github.com/vaskoz/dailycodingproblem-go/issues/227)
 * [Day 109](https://github.com/vaskoz/dailycodingproblem-go/issues/229)
+* [Day 111](https://github.com/vaskoz/dailycodingproblem-go/issues/232)
diff --git a/day111/problem.go b/day111/problem.go
new file mode 100644
index 0000000..ace9b37
--- /dev/null
+++ b/day111/problem.go
@@ -0,0 +1,24 @@
+package day111
+
+import "reflect"
+
+// StartIndicesAnagrams returns all the starting indices (0-based)
+// for the anagrams of W in the longer string S.
+// Runs in O(N*M) time where N is len(word) and M is len(str).
+func StartIndicesAnagrams(W string, S string) []int {
+	freq := make(map[rune]int)
+	for _, r := range W {
+		freq[r]++
+	}
+	var result []int
+	for i := range S {
+		sub := make(map[rune]int)
+		for j := i; j < len(S) && j < i+len(W); j++ {
+			sub[rune(S[j])]++
+		}
+		if reflect.DeepEqual(sub, freq) {
+			result = append(result, i)
+		}
+	}
+	return result
+}


Test patch:
diff --git a/day111/problem_test.go b/day111/problem_test.go
new file mode 100644
index 0000000..baa3e22
--- /dev/null
+++ b/day111/problem_test.go
@@ -0,0 +1,31 @@
+package day111
+
+import (
+	"reflect"
+	"testing"
+)
+
+var testcases = []struct {
+	W, S     string
+	expected []int
+}{
+	{"ab", "abxaba", []int{0, 3, 4}},
+	{"ba", "abxaba", []int{0, 3, 4}},
+	{"aabx", "abxaba", []int{0, 2}},
+}
+
+func TestStartIndicesAnagrams(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := StartIndicesAnagrams(tc.W, tc.S); !reflect.DeepEqual(tc.expected, result) {
+			t.Errorf("Expected %v got %v", tc.expected, result)
+		}
+	}
+}
+func BenchmarkStartIndicesAnagrams(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			StartIndicesAnagrams(tc.W, tc.S)
+		}
+	}
+}
Repository: tighten/tlint (php)
Issue: Exempt protected setUp/tearDown for ClassThingsOrder
If you have a setup method, it has to be declared protected, but then we get a lint warning. Can we make an exception for the setUp method and possibly also teardown? (As they are protected, but we still likely want them at the top, #edgeCase)

Pull request description: Exempt protected setUp/tearDown for ClassThingsOrder.
Closes #204 

Patch:
diff --git a/src/Linters/ClassThingsOrder.php b/src/Linters/ClassThingsOrder.php
index 1e16f08..3954e94 100644
--- a/src/Linters/ClassThingsOrder.php
+++ b/src/Linters/ClassThingsOrder.php
@@ -84,6 +84,15 @@ class ClassThingsOrder extends BaseLinter
 
                     throw new Exception('Unknown statement');
                 }, array_filter($node->stmts, function (Node\Stmt $stmt) {
+                    // Ignore PhpUnit protected setUp/tearDown method
+                    if ($stmt instanceof Node\Stmt\ClassMethod
+                        && $stmt->isProtected()
+                        && in_array($stmt->name->toString(), ['setUp', 'tearDown'])
+                        && $stmt->returnType->toString() === 'void'
+                    ) {
+                        return false;
+                    }
+
                     return ! $stmt instanceof Node\Stmt\Nop;
                 }));
 


Test patch:
diff --git a/tests/Linting/Linters/ClassThingsOrderTest.php b/tests/Linting/Linters/ClassThingsOrderTest.php
index 9271c9f..4fdb9be 100644
--- a/tests/Linting/Linters/ClassThingsOrderTest.php
+++ b/tests/Linting/Linters/ClassThingsOrderTest.php
@@ -135,4 +135,74 @@ file;
 
         $this->assertEquals(3, $lints[0]->getNode()->getLine());
     }
+
+    /** @test */
+    function does_not_trigger_on_setup_setup() {
+        $file = <<<file
+<?php
+
+namespace Tests\Feature;
+
+use Illuminate\Foundation\Testing\RefreshDatabase;
+use Tests\TestCase;
+
+class ResourceSearchTest extends TestCase
+{
+    use RefreshDatabase;
+
+    protected function setUp(): void
+    {
+        // Do stuff
+        parent::setUp();
+    }
+
+    /** @test */
+    function true_is_true()
+    {
+        \$this->assertTrue(true);
+    }
+}
+file;
+
+        $lints = (new TLint)->lint(
+            new ClassThingsOrder($file)
+        );
+
+        $this->assertEmpty($lints);
+    }
+
+    /** @test */
+    function does_not_trigger_on_phpunit_teardown() {
+        $file = <<<file
+<?php
+
+namespace Tests\Feature;
+
+use Illuminate\Foundation\Testing\RefreshDatabase;
+use Tests\TestCase;
+
+class ResourceSearchTest extends TestCase
+{
+    use RefreshDatabase;
+
+    protected function tearDown(): void
+    {
+        // Do stuff
+        parent::tearDown();
+    }
+
+    /** @test */
+    function true_is_true()
+    {
+        \$this->assertTrue(true);
+    }
+}
+file;
+
+        $lints = (new TLint)->lint(
+            new ClassThingsOrder($file)
+        );
+
+        $this->assertEmpty($lints);
+    }
 }
Repository: gobuffalo/pop (go)
Issue: Reconnect DB after closing.
## Description

If this is a feature request, explain why it should be added. Specific use-cases are best.

For bug reports, please provide as much *relevant* info as possible.
 
When `Connection`  closed, it unable to open again.

### Steps to Reproduce the Problem

  Please describe in painful detail what you did (so others can play along with you) to get to this point. This includes things like the exact command(s) you used, or the `curl` command you used, that sort of thing.

```go
	users := []User{}
	for i := 0; i < 2; i++ {
		conn, err := pop.Connect("development")
		if err != nil {
			fmt.Println(err)
		}
		err = conn.All(&users)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		for _, u := range users {
			fmt.Println(u)
		}
		err = conn.Close()
		// conn.Store = nil // make Store to nil will continue the loop
		if err != nil {
			fmt.Println(err)
		}
	}
```
### Expected Behavior

connection will recconnect after closing

### Actual Behavior

```
unable to fetch records: sql: database is closed
```

### Info

Should set `Store = nil`  in Connection's Close method.

Pull request description: fix Connection.Close() to reset the store
As reported in #510, the `Connection.Close()` just closes the connection to the database but did not update the status of `Connection` so it could not be reused with `Open()`. 

This PR makes the method to reset `Store` so `Open()` can understand the status of the `Connection`. Also, added a test case for this issue.

fixes #510

Patch:
diff --git a/connection.go b/connection.go
index f51fd36..1fe2253 100644
--- a/connection.go
+++ b/connection.go
@@ -145,6 +145,7 @@ func (c *Connection) Close() error {
 	if err := c.Store.Close(); err != nil {
 		return fmt.Errorf("couldn't close connection: %w", err)
 	}
+	c.Store = nil
 	return nil
 }
 


Test patch:
diff --git a/connection_test.go b/connection_test.go
index 55c801e..90d5614 100644
--- a/connection_test.go
+++ b/connection_test.go
@@ -28,6 +28,21 @@ func Test_Connection_SimpleFlow(t *testing.T) {
 	r.NoError(err)
 }
 
+func Test_Connection_Open_Close_Reopen(t *testing.T) {
+	r := require.New(t)
+
+	c, err := NewConnection(&ConnectionDetails{
+		URL: "sqlite://file::memory:?_fk=true",
+	})
+	r.NoError(err)
+
+	for i := 0; i < 2; i++ {
+		r.NoError(c.Open())
+		r.NoError(c.Transaction(func(c *Connection) error { return nil }))
+		r.NoError(c.Close())
+	}
+}
+
 func Test_Connection_Open_NoDialect(t *testing.T) {
 	r := require.New(t)
Repository: vue-a11y/eslint-plugin-vuejs-accessibility (ts)
Issue: click-event-has-key-events doesn't always pick up click directive
A co-worker noticed some inconsistency on when this rule throws an error. In our particular use case, these two versions throw the linting error as expected:

```vue
<button @click.prevent="isExpanded = !isExpanded">
```

```vue
<button @click.prevent="toggleIsExpanded()">
```

However, this one doesn't throw the linting error.

```vue
<button @click.prevent="toggleIsExpanded">
```

This is in Vue 3, for what it's worth.
Pull request description: Fix for #145
Fixes #145

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e0c077e..917e6d9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
 
 ## [Unreleased]
 
+### Changed
+
+- Ensure directives that have identifiers for values are counted as present in the element.
+
 ## [0.6.2] - 2021-05-26
 
 ### Changed
diff --git a/src/utils/hasOnDirective.js b/src/utils/hasOnDirective.js
index bf02201..50aae24 100644
--- a/src/utils/hasOnDirective.js
+++ b/src/utils/hasOnDirective.js
@@ -9,7 +9,7 @@ const hasOnDirective = (node, name) =>
       key.argument.name === name &&
       value &&
       value.expression &&
-      !!value.expression.body
+      (value.expression.type === "Identifier" || !!value.expression.body)
     );
   });
 


Test patch:
diff --git a/src/rules/__tests__/click-events-have-key-events.test.js b/src/rules/__tests__/click-events-have-key-events.test.js
index e3cc07b..6b0c209 100644
--- a/src/rules/__tests__/click-events-have-key-events.test.js
+++ b/src/rules/__tests__/click-events-have-key-events.test.js
@@ -27,6 +27,7 @@ makeRuleTester("click-events-have-key-events", rule, {
     "<Button @click='void 0' />"
   ],
   invalid: [
+    "<div @click='toggle'>",
     "<div @click='void 0' />",
     "<div @click='void 0' role='undefined' />",
     "<section @click='void 0' />",
Repository: goreleaser/nfpm (go)
Issue: Confusing behaviour with trailing `/` in destination
### What happened?

I have the following nfpm.yaml:

```yml
name: foo
version: 0.0.0
maintainer: asdf
arch: amd64
contents:
- dst: /usr/local/share/file/
  src: file.txt
```

Note the `/` at the end of the destination path. Because of that, I expect nfpm to install the file as `/usr/local/share/file/file.txt`. However, it installs the file as `/usr/local/share/file`. This is confusing because the trailing `/` indicates that the path is a directory, so the logical course of action would be to put the file into the directory.

### How can we reproduce this?

Copy the above nfpm.yaml, and create a file `file.txt`, and run `nfpm package -p deb`

### nfpm version

```bash
nfpm version nfpm version 2.22.0
commit: 5c3cc38943f1743bcaeb422c2dc65555fc9b12a1
built at: 2022-11-12T03:50:16Z
built by: goreleaser
module version: v2.22.0, checksum: h1:TC6tuxxFq0hL0WapI63+CkLMbcsYRbR7kAnLkRYAEbo=
```


### Search

- [X] I did search for other open and closed issues before opening this.

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Additional context

_No response_
Pull request description: fix: relative paths to dirs
closes #575

Patch:
diff --git a/internal/glob/glob.go b/internal/glob/glob.go
index e225147..e6fca62 100644
--- a/internal/glob/glob.go
+++ b/internal/glob/glob.go
@@ -92,6 +92,11 @@ func Glob(pattern, dst string, ignoreMatchers bool) (map[string]string, error) {
 			continue
 		}
 
+		if strings.HasSuffix(dst, "/") {
+			files[src] = filepath.Join(dst, filepath.Base(src))
+			continue
+		}
+
 		relpath, err := filepath.Rel(prefix, src)
 		if err != nil {
 			// since prefix is a prefix of src a relative path should always be found


Test patch:
diff --git a/files/files_test.go b/files/files_test.go
index 2166267..06dceee 100644
--- a/files/files_test.go
+++ b/files/files_test.go
@@ -370,3 +370,15 @@ func TestGlobbingFilesWithDifferentSizesWithFileInfo(t *testing.T) {
 		t.Fatal("test FileInfos have the same size, expected different")
 	}
 }
+
+func TestDestEndsWithSlash(t *testing.T) {
+	result, err := files.ExpandContentGlobs(files.Contents{
+		{
+			Source:      "./testdata/globtest/a.txt",
+			Destination: "./foo/",
+		},
+	}, false)
+	require.NoError(t, err)
+	require.Len(t, result, 1)
+	require.Equal(t, "foo/a.txt", result[0].Destination)
+}
diff --git a/internal/glob/glob_test.go b/internal/glob/glob_test.go
index 721b3c8..d21daab 100644
--- a/internal/glob/glob_test.go
+++ b/internal/glob/glob_test.go
@@ -47,6 +47,13 @@ func TestGlob(t *testing.T) {
 		require.Equal(t, "/foo/bar/dir_c/test_c.txt", files["testdata/dir_a/dir_c/test_c.txt"])
 	})
 
+	t.Run("dst is a dir", func(t *testing.T) {
+		files, err := Glob("./testdata/dir_a/dir_b/test_b.txt", "/foo/bar/", false)
+		require.NoError(t, err)
+		require.Len(t, files, 1)
+		require.Equal(t, "/foo/bar/test_b.txt", files["testdata/dir_a/dir_b/test_b.txt"])
+	})
+
 	t.Run("to parent", func(t *testing.T) {
 		pattern := "../../testdata/fake"
 		abs, err := filepath.Abs(pattern)
Repository: MiSawa/xq (rust)
Issue: flatten/1 on empty array emits null instead of []
The flatten filter on empty array should emit an empty array.
```sh
❯ jq -n '[] | flatten(0)'
[]

❯ xq -n '[] | flatten(0)'
null

❯ xq --version
xq 0.2.10-ad33a92d252fc4842f10730973e16f5da8434035
```
Pull request description: Fix flatten/1 on empty array
Fix #98 

Patch:
diff --git a/prelude.jq b/prelude.jq
index d7818c0..51c1424 100644
--- a/prelude.jq
+++ b/prelude.jq
@@ -70,7 +70,7 @@ def unique_by(f): def __yes_i_know_this_is_bad:.; [group_by(f)[] | .[0]];
 def unique: unique_by(.);
 
 def flatten: if type | . == "array" or . == "object" then [.[] | flatten] | reduce .[] as $v ([]; . + $v) else [.] end;
-def flatten($d): if ($d >= 0) and (type | . == "array" or . == "object") then [.[] | flatten($d-1)] | add else [.] end;
+def flatten($d): if ($d >= 0) and (type | . == "array" or . == "object") then [.[] | flatten($d-1)] | reduce .[] as $v ([]; . + $v) else [.] end;
 
 def index($s): def __yes_i_know_this_is_bad:.; indices($s)[0];
 def rindex($s): def __yes_i_know_this_is_bad:.; indices($s)[-1];


Test patch:
diff --git a/tests/hand_written/mod.rs b/tests/hand_written/mod.rs
index ea1c28c..da44901 100644
--- a/tests/hand_written/mod.rs
+++ b/tests/hand_written/mod.rs
@@ -666,3 +666,20 @@ test!(
     {"a":2,"b":3}
     "#
 );
+
+test!(
+    empty_flatten,
+    r#"
+    flatten(0, 1)
+    "#,
+    r#"
+    []
+    [[], []]
+    "#,
+    r#"
+    []
+    []
+    [[],[]]
+    []
+    "#
+);
Repository: caarlos0/env (go)
Issue: Bug: fails to parse into fields with value
A regression was introduced in v7. When we pass a struct with non-nil pointer fields, `Parse` fails.

```go
func TestIssue(t *testing.T) {
	t.Run("Should parse with bool ptr set and env undefined", func(t *testing.T) {
		existingValue := true
		cfg := Config{
			BoolPtr: &existingValue,
		}

		isNoErr(t, Parse(&cfg))

		isEqual(t, &existingValue, cfg.BoolPtr)
	})

	t.Run("Should parse with bool ptr set and env defined", func(t *testing.T) {
		existingValue := true
		cfg := Config{
			BoolPtr: &existingValue,
		}

		newValue := false
		t.Setenv("BOOL", strconv.FormatBool(newValue))

		isNoErr(t, Parse(&cfg))

		isEqual(t, &newValue, cfg.BoolPtr)
	})
}
```

In 850c2d8 - this test passes.

In b135bbd and up to the current main - this test fails.

```
=== RUN   TestIssue/Should_parse_with_bool_ptr_set_and_env_undefined
    env_test.go:2199: unexpected error: env: expected a pointer to a Struct
```
Pull request description: Fix issue parsing into ptr fields with value
Closes #339

Patch:
diff --git a/env.go b/env.go
index d24c32e..b815e79 100644
--- a/env.go
+++ b/env.go
@@ -355,7 +355,7 @@ func doParseField(
 	if !refField.CanSet() {
 		return nil
 	}
-	if reflect.Ptr == refField.Kind() && !refField.IsNil() {
+	if reflect.Ptr == refField.Kind() && refField.Elem().Kind() == reflect.Struct && !refField.IsNil() {
 		return parseInternal(refField.Interface(), processField, optionsWithEnvPrefix(refTypeField, opts))
 	}
 	if reflect.Struct == refField.Kind() && refField.CanAddr() && refField.Type().Name() == "" {


Test patch:
diff --git a/env_test.go b/env_test.go
index 3ccaae4..6017889 100644
--- a/env_test.go
+++ b/env_test.go
@@ -2254,3 +2254,55 @@ func TestNoEnvKeyIgnored(t *testing.T) {
 	isEqual(t, "", cfg.Foo)
 	isEqual(t, "202", cfg.FooBar)
 }
+
+func TestIssue339(t *testing.T) {
+	t.Run("Should parse with bool ptr set and env undefined", func(t *testing.T) {
+		existingValue := true
+		cfg := Config{
+			BoolPtr: &existingValue,
+		}
+
+		isNoErr(t, Parse(&cfg))
+
+		isEqual(t, &existingValue, cfg.BoolPtr)
+	})
+
+	t.Run("Should parse with bool ptr set and env defined", func(t *testing.T) {
+		existingValue := true
+		cfg := Config{
+			BoolPtr: &existingValue,
+		}
+
+		newValue := false
+		t.Setenv("BOOL", strconv.FormatBool(newValue))
+
+		isNoErr(t, Parse(&cfg))
+
+		isEqual(t, &newValue, cfg.BoolPtr)
+	})
+
+	t.Run("Should parse with string ptr set and env undefined", func(t *testing.T) {
+		existingValue := "one"
+		cfg := Config{
+			StringPtr: &existingValue,
+		}
+
+		isNoErr(t, Parse(&cfg))
+
+		isEqual(t, &existingValue, cfg.StringPtr)
+	})
+
+	t.Run("Should parse with string ptr set and env defined", func(t *testing.T) {
+		existingValue := "one"
+		cfg := Config{
+			StringPtr: &existingValue,
+		}
+
+		newValue := "two"
+		t.Setenv("STRING", newValue)
+
+		isNoErr(t, Parse(&cfg))
+
+		isEqual(t, &newValue, cfg.StringPtr)
+	})
+}