Skip to content

Commit 84a57f3

Browse files
Patching issues #44, #42, #41, #40
1 parent 951c7dd commit 84a57f3

6 files changed

Lines changed: 85 additions & 69 deletions

File tree

src/metacheck/scripts/pitfalls/p002.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def extract_license_from_file(somef_data: Dict) -> Optional[Dict[str, str]]:
1717
for entry in license_entries:
1818
if "source" in entry:
1919
source = entry["source"]
20-
if "LICENSE.md" in source:
20+
if "license" in source.lower():
2121
if "result" in entry and "value" in entry["result"]:
2222
return {
2323
"source": source,

src/metacheck/scripts/pitfalls/p008.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ def check_url_status(url: str, timeout: int = 10) -> Dict:
3636
result["error"] = "Invalid URL format"
3737
return result
3838

39+
if url.startswith(('git+', 'git://', 'svn+', 'hg+', 'bzr+')):
40+
result["is_accessible"] = True
41+
result["status_code"] = 200
42+
return result
43+
3944
try:
4045
headers = {
4146
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'

src/metacheck/scripts/tests/test_w003.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class TestDetectDualLicenseMissingCodemetaPitfall:
66
"""Test suite for detect_dual_license_missing_codemeta_pitfall function"""
77

88
@pytest.mark.parametrize(
9-
"somef_data,file_name,expected_has_pitfall,expected_dual_indicator,expected_codemeta_count",
9+
"somef_data,file_name,expected_has_warning,expected_dual_indicator,expected_codemeta_count",
1010
[
1111
# No license key
1212
(
@@ -363,12 +363,12 @@ class TestDetectDualLicenseMissingCodemetaPitfall:
363363
1
364364
),
365365
])
366-
def test_detect_pitfall_scenarios(self, somef_data, file_name, expected_has_pitfall,
366+
def test_detect_pitfall_scenarios(self, somef_data, file_name, expected_has_warning,
367367
expected_dual_indicator, expected_codemeta_count):
368368
"""Test various dual license missing codemeta scenarios"""
369369
result = detect_dual_license_missing_codemeta_pitfall(somef_data, file_name)
370370

371-
assert result["has_pitfall"] == expected_has_pitfall
371+
assert result["has_warning"] == expected_has_warning
372372
assert result["file_name"] == file_name
373373
assert result["has_dual_license_indicator"] == expected_dual_indicator
374374
assert result["codemeta_license_count"] == expected_codemeta_count
@@ -381,7 +381,7 @@ def test_result_structure(self):
381381
somef_data = {}
382382
result = detect_dual_license_missing_codemeta_pitfall(somef_data, "test.json")
383383

384-
assert "has_pitfall" in result
384+
assert "has_warning" in result
385385
assert "file_name" in result
386386
assert "has_dual_license_indicator" in result
387387
assert "codemeta_license_count" in result
@@ -433,7 +433,7 @@ def test_multiple_codemeta_licenses_no_pitfall(self):
433433
}
434434

435435
result = detect_dual_license_missing_codemeta_pitfall(somef_data, "test.json")
436-
assert result["has_pitfall"] == False
436+
assert result["has_warning"] == False
437437
assert result["codemeta_license_count"] == 3
438438

439439
def test_all_dual_license_patterns(self):
@@ -469,7 +469,7 @@ def test_all_dual_license_patterns(self):
469469

470470
result = detect_dual_license_missing_codemeta_pitfall(somef_data, "test.json")
471471
assert result["has_dual_license_indicator"] == True, f"Pattern '{pattern}' not detected"
472-
assert result["has_pitfall"] == True
472+
assert result["has_warning"] == True
473473

474474
def test_non_codemeta_technique_not_counted(self):
475475
"""Test that non-code_parser technique doesn't count as codemeta license"""
@@ -489,7 +489,7 @@ def test_non_codemeta_technique_not_counted(self):
489489

490490
result = detect_dual_license_missing_codemeta_pitfall(somef_data, "test.json")
491491
assert result["codemeta_license_count"] == 0
492-
assert result["has_pitfall"] == True
492+
assert result["has_warning"] == True
493493

494494
def test_first_dual_license_pattern_wins(self):
495495
"""Test that first matching pattern sets the source"""
@@ -535,7 +535,7 @@ def test_missing_result_or_value_handled(self):
535535
}
536536

537537
result = detect_dual_license_missing_codemeta_pitfall(somef_data, "test.json")
538-
assert result["has_pitfall"] == False
538+
assert result["has_warning"] == False
539539
assert result["codemeta_license_count"] == 1
540540

541541
def test_edge_case_exactly_one_codemeta_license(self):
@@ -556,7 +556,7 @@ def test_edge_case_exactly_one_codemeta_license(self):
556556

557557
result = detect_dual_license_missing_codemeta_pitfall(somef_data, "test.json")
558558
assert result["codemeta_license_count"] == 1
559-
assert result["has_pitfall"] == True
559+
assert result["has_warning"] == True
560560

561561
def test_edge_case_exactly_two_codemeta_licenses(self):
562562
"""Test boundary condition with exactly 2 codemeta licenses"""
@@ -581,4 +581,4 @@ def test_edge_case_exactly_two_codemeta_licenses(self):
581581

582582
result = detect_dual_license_missing_codemeta_pitfall(somef_data, "test.json")
583583
assert result["codemeta_license_count"] == 2
584-
assert result["has_pitfall"] == False
584+
assert result["has_warning"] == False

src/metacheck/scripts/tests/test_w009.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class TestDetectDevelopmentStatusUrlPitfall:
8080
"""Test suite for detect_development_status_url_pitfall function"""
8181

8282
@pytest.mark.parametrize(
83-
"somef_data,file_name,expected_has_pitfall,expected_status,expected_is_url", [
83+
"somef_data,file_name,expected_has_warning,expected_status,expected_is_url", [
8484
# No development_status key
8585
(
8686
{},
@@ -332,12 +332,12 @@ class TestDetectDevelopmentStatusUrlPitfall:
332332
),
333333
])
334334
def test_detect_development_status_url_scenarios(self, somef_data, file_name,
335-
expected_has_pitfall, expected_status,
335+
expected_has_warning, expected_status,
336336
expected_is_url):
337337
"""Test various scenarios for development status URL detection"""
338338
result = detect_development_status_url_pitfall(somef_data, file_name)
339339

340-
assert result["has_pitfall"] == expected_has_pitfall
340+
assert result["has_warning"] == expected_has_warning
341341
assert result["file_name"] == file_name
342342
assert result["development_status"] == expected_status
343343
assert result["is_url"] == expected_is_url
@@ -347,7 +347,7 @@ def test_result_structure(self):
347347
somef_data = {}
348348
result = detect_development_status_url_pitfall(somef_data, "test.json")
349349

350-
assert "has_pitfall" in result
350+
assert "has_warning" in result
351351
assert "file_name" in result
352352
assert "development_status" in result
353353
assert "source" in result
@@ -372,7 +372,7 @@ def test_stops_at_first_match(self):
372372

373373
result = detect_development_status_url_pitfall(somef_data, "test.json")
374374

375-
assert result["has_pitfall"] is True
375+
assert result["has_warning"] is True
376376
assert result["development_status"] == "https://example.com"
377377

378378
@pytest.mark.parametrize("url_value", [
@@ -394,7 +394,7 @@ def test_various_url_formats(self, url_value):
394394
}
395395

396396
result = detect_development_status_url_pitfall(somef_data, "test.json")
397-
assert result["has_pitfall"] is True
397+
assert result["has_warning"] is True
398398
assert result["development_status"] == url_value
399399

400400
@pytest.mark.parametrize("valid_status", [
@@ -420,7 +420,7 @@ def test_valid_status_strings(self, valid_status):
420420
}
421421

422422
result = detect_development_status_url_pitfall(somef_data, "test.json")
423-
assert result["has_pitfall"] is False
423+
assert result["has_warning"] is False
424424

425425
def test_source_variations(self):
426426
"""Test various source path formats for codemeta.json"""
@@ -445,7 +445,7 @@ def test_source_variations(self):
445445
}
446446

447447
result = detect_development_status_url_pitfall(somef_data, "test.json")
448-
assert result["has_pitfall"] == should_trigger, f"Failed for source: {source}"
448+
assert result["has_warning"] == should_trigger, f"Failed for source: {source}"
449449

450450
def test_non_string_values(self):
451451
"""Test that non-string values don't cause errors"""
@@ -467,4 +467,4 @@ def test_non_string_values(self):
467467
}
468468

469469
result = detect_development_status_url_pitfall(somef_data, "test.json")
470-
assert result["has_pitfall"] is False
470+
assert result["has_warning"] is False

src/metacheck/scripts/tests/test_w010.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class TestDetectGitRemoteShorthandPitfall:
9292
"""Test suite for detect_git_remote_shorthand_pitfall function"""
9393

9494
@pytest.mark.parametrize(
95-
"somef_data,file_name,expected_has_pitfall,expected_url,expected_source_file", [
95+
"somef_data,file_name,expected_has_warning,expected_url,expected_source_file", [
9696
# No code_repository key
9797
(
9898
{},
@@ -329,27 +329,27 @@ class TestDetectGitRemoteShorthandPitfall:
329329
),
330330
])
331331
def test_detect_git_shorthand_scenarios(self, somef_data, file_name,
332-
expected_has_pitfall, expected_url,
332+
expected_has_warning, expected_url,
333333
expected_source_file):
334334
"""Test various scenarios for Git remote shorthand detection"""
335335
with patch('metacheck.scripts.warnings.w010.extract_metadata_source_filename',
336336
return_value=expected_source_file):
337337
result = detect_git_remote_shorthand_pitfall(somef_data, file_name)
338338

339-
assert result["has_pitfall"] == expected_has_pitfall
339+
assert result["has_warning"] == expected_has_warning
340340
assert result["file_name"] == file_name
341341
assert result["repository_url"] == expected_url
342-
assert result["is_shorthand"] == expected_has_pitfall
342+
assert result["is_shorthand"] == expected_has_warning
343343

344-
if expected_has_pitfall:
344+
if expected_has_warning:
345345
assert result["metadata_source_file"] == expected_source_file
346346

347347
def test_result_structure(self):
348348
"""Test that result always has the expected structure"""
349349
somef_data = {}
350350
result = detect_git_remote_shorthand_pitfall(somef_data, "test.json")
351351

352-
assert "has_pitfall" in result
352+
assert "has_warning" in result
353353
assert "file_name" in result
354354
assert "repository_url" in result
355355
assert "source" in result
@@ -374,7 +374,7 @@ def test_all_metadata_sources(self, metadata_file):
374374
with patch('metacheck.scripts.warnings.w010.extract_metadata_source_filename',
375375
return_value=metadata_file):
376376
result = detect_git_remote_shorthand_pitfall(somef_data, "test.json")
377-
assert result["has_pitfall"] is True
377+
assert result["has_warning"] is True
378378
assert result["metadata_source_file"] == metadata_file
379379

380380
def test_stops_at_first_match(self):
@@ -398,7 +398,7 @@ def test_stops_at_first_match(self):
398398
side_effect=["codemeta.json", "package.json"]):
399399
result = detect_git_remote_shorthand_pitfall(somef_data, "test.json")
400400

401-
assert result["has_pitfall"] is True
401+
assert result["has_warning"] is True
402402
assert result["repository_url"] == "github.com:user/repo1.git"
403403

404404
@pytest.mark.parametrize("shorthand_url", [
@@ -421,7 +421,7 @@ def test_various_shorthand_formats(self, shorthand_url):
421421
with patch('metacheck.scripts.warnings.w010.extract_metadata_source_filename',
422422
return_value="codemeta.json"):
423423
result = detect_git_remote_shorthand_pitfall(somef_data, "test.json")
424-
assert result["has_pitfall"] is True
424+
assert result["has_warning"] is True
425425
assert result["repository_url"] == shorthand_url
426426

427427
def test_missing_technique_field(self):
@@ -437,4 +437,4 @@ def test_missing_technique_field(self):
437437
return_value="codemeta.json"):
438438
result = detect_git_remote_shorthand_pitfall(somef_data, "test.json")
439439
# Should still detect based on source matching
440-
assert result["has_pitfall"] is True
440+
assert result["has_warning"] is True

0 commit comments

Comments
 (0)