PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: spatie/opening-hours (php)
Issue: previousOpen returns next open date
Hi! We are using your library (2.41.0) and looking for a way to find last opening time. As I understand `previousOpen` should do this, but seems that response is not correct. I tried to setup next opening hours:
* Monday: 18:00 - 05:00
* Tuesday: 18:00 - 05:00
And `previousOpen` with (Tuesday 06:00) returns (Tuesday 18:00), but I expect (Monday 18:00). So it returns `nextOpen`.

Created a test file such as:
```php
$openingHours = OpeningHours::create([
    'overflow' => true,
    'monday' => ['18:00-05:00'],
    'tuesday' => ['18:00-05:00'],
]);
$tuesday = new DateTime('2024-06-11 06:00:00');
echo 'Today          : ' . $tuesday->format('Y-m-d H:i') . "\n";
echo 'Previous open  : ' . $openingHours->previousOpen($tuesday)->format('Y-m-d H:i') . "\n";
echo 'Previous close : ' . $openingHours->previousClose($tuesday)->format('Y-m-d H:i') . "\n";
```
Response
``` cmd
Today          : 2024-06-11 06:00
Previous open  : 2024-06-11 18:00
Previous close : 2024-06-11 05:00
```
Could you please say if there's a problem with configuration or there any solution to solve this issue?
Pull request description: Check both start and end to consider a range before/after
Check both start and end to consider a range before/after

Fix #243

Patch:
diff --git a/src/Helpers/RangeFinder.php b/src/Helpers/RangeFinder.php
index 7dcf67c..77021da 100644
--- a/src/Helpers/RangeFinder.php
+++ b/src/Helpers/RangeFinder.php
@@ -44,7 +44,7 @@ trait RangeFinder
 
     protected function findPreviousRangeInFreeTime(Time $time, TimeRange $timeRange): ?TimeRange
     {
-        return $time->isAfter($timeRange->end()) ? $timeRange : null;
+        return $time->isAfter($timeRange->end()) && $time->isAfter($timeRange->start()) ? $timeRange : null;
     }
 
     protected function findPreviousOpenInFreeTime(Time $time, TimeRange $timeRange): ?Time


Test patch:
diff --git a/tests/OpeningHoursOverflowTest.php b/tests/OpeningHoursOverflowTest.php
index dc98ad1..1a9aebb 100644
--- a/tests/OpeningHoursOverflowTest.php
+++ b/tests/OpeningHoursOverflowTest.php
@@ -142,6 +142,20 @@ class OpeningHoursOverflowTest extends TestCase
         $this->assertSame('2019-04-22 02:00:00', $previousTimeOpen);
     }
 
+    #[Test]
+    public function previous_open_and_close_with_overflow_immutable()
+    {
+        $openingHours = OpeningHours::create([
+            'overflow' => true,
+            'monday' => ['18:00-05:00'],
+            'tuesday' => ['18:00-05:00'],
+        ]);
+        $tuesday = new DateTime('2024-06-11 06:00:00');
+
+        $this->assertSame('2024-06-10 18:00', $openingHours->previousOpen($tuesday)->format('Y-m-d H:i'));
+        $this->assertSame('2024-06-11 05:00', $openingHours->previousClose($tuesday)->format('Y-m-d H:i'));
+    }
+
     #[Test]
     public function overflow_on_simple_ranges()
     {
Repository: go-kit/kit (go)
Issue: Can't reuse sync logger when panic and recovered
When using sync logger and the given logger panic, that sync logger can't be reuse again because of forever locked mutex. 

Can we just defer the `Unlock()`?
Pull request description: log: SyncLogger: defer mutex unlocks for panic safety
Closes #973

Patch:
diff --git a/log/sync.go b/log/sync.go
index c07cdfa..58bd3ad 100644
--- a/log/sync.go
+++ b/log/sync.go
@@ -65,9 +65,8 @@ type syncWriter struct {
 // progress, the calling goroutine blocks until the syncWriter is available.
 func (w *syncWriter) Write(p []byte) (n int, err error) {
 	w.Lock()
-	n, err = w.Writer.Write(p)
-	w.Unlock()
-	return n, err
+	defer w.Unlock()
+	return w.Writer.Write(p)
 }
 
 // fdWriter is an io.Writer that also has an Fd method. The most common
@@ -87,9 +86,8 @@ type fdSyncWriter struct {
 // progress, the calling goroutine blocks until the fdSyncWriter is available.
 func (w *fdSyncWriter) Write(p []byte) (n int, err error) {
 	w.Lock()
-	n, err = w.fdWriter.Write(p)
-	w.Unlock()
-	return n, err
+	defer w.Unlock()
+	return w.fdWriter.Write(p)
 }
 
 // syncLogger provides concurrent safe logging for another Logger.
@@ -110,7 +108,6 @@ func NewSyncLogger(logger Logger) Logger {
 // progress, the calling goroutine blocks until the syncLogger is available.
 func (l *syncLogger) Log(keyvals ...interface{}) error {
 	l.mu.Lock()
-	err := l.logger.Log(keyvals...)
-	l.mu.Unlock()
-	return err
+	defer l.mu.Unlock()
+	return l.logger.Log(keyvals...)
 }


Test patch:
diff --git a/log/sync_test.go b/log/sync_test.go
index 55e6b15..253f256 100644
--- a/log/sync_test.go
+++ b/log/sync_test.go
@@ -81,3 +81,21 @@ func TestSyncWriterFd(t *testing.T) {
 		t.Error("NewSyncWriter does not pass through Fd method")
 	}
 }
+
+func TestSyncLoggerPanic(t *testing.T) {
+	var logger log.Logger
+	logger = log.LoggerFunc(func(...interface{}) error { panic("!") })
+	logger = log.NewSyncLogger(logger)
+
+	f := func() {
+		defer func() {
+			if x := recover(); x != nil {
+				t.Log(x)
+			}
+		}()
+		logger.Log("hello", "world")
+	}
+
+	f()
+	f() // without defer Unlock, this one can deadlock
+}
Repository: mgechev/revive (go)
Issue: `time-equal` garbled message when time returned from function
**Describe the bug**
The `time-equal` rule passes an `ast.Expr` to a `%s` placeholder in its message format, but not all `ast.Expr` implement `String()`, so junk is output for certain kinds of expressions (such as comparing a `time.Time` that's returned from a function call).

**To Reproduce**
Steps to reproduce the behavior:
1. I updated revive `go install github.com/mgechev/revive@latest`
2. I run it with the following flags & configuration file:

```shell
revive -config revive.toml time-equal-test.go
```

```toml
# config file
ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.0
errorCode = 0
warningCode = 0

[rule.time-equal]
```

Source file `time-equal-test.go`:

```go
package test

import "time"

func isNow(t time.Time) bool { return t == time.Now() }

```

**Expected behavior**
Something more readable than:

```
time-equal-test.go:5:39: use t.Equal(&{%!s(*ast.SelectorExpr=&{0xc00007e7a0 0xc00007e7c0}) %!s(token.Pos=81) [] %!s(token.Pos=0) %!s(token.Pos=82)}) instead of "==" operator
```
Pull request description: fix #846: time-equal garbled message when time returned from function
Closes #846 


Patch:
diff --git a/rule/time-equal.go b/rule/time-equal.go
index 72ecf26..3b85e18 100644
--- a/rule/time-equal.go
+++ b/rule/time-equal.go
@@ -60,9 +60,9 @@ func (l *lintTimeEqual) Visit(node ast.Node) ast.Visitor {
 	var failure string
 	switch expr.Op {
 	case token.EQL:
-		failure = fmt.Sprintf("use %s.Equal(%s) instead of %q operator", expr.X, expr.Y, expr.Op)
+		failure = fmt.Sprintf("use %s.Equal(%s) instead of %q operator", gofmt(expr.X), gofmt(expr.Y), expr.Op)
 	case token.NEQ:
-		failure = fmt.Sprintf("use !%s.Equal(%s) instead of %q operator", expr.X, expr.Y, expr.Op)
+		failure = fmt.Sprintf("use !%s.Equal(%s) instead of %q operator", gofmt(expr.X), gofmt(expr.Y), expr.Op)
 	}
 
 	l.onFailure(lint.Failure{


Test patch:
diff --git a/testdata/time-equal.go b/testdata/time-equal.go
index be72c4e..f31a05a 100644
--- a/testdata/time-equal.go
+++ b/testdata/time-equal.go
@@ -12,3 +12,7 @@ func t() bool {
 
 	return t != u // MATCH /use !t.Equal(u) instead of "!=" operator/
 }
+
+// issue #846
+func isNow(t time.Time) bool    { return t == time.Now() } // MATCH /use t.Equal(time.Now()) instead of "==" operator/
+func isNotNow(t time.Time) bool { return time.Now() != t } // MATCH /use !time.Now().Equal(t) instead of "!=" operator/