16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/denmark/plugins/metadata.rb', line 16
def self.run(mod, repo)
response = Array.new
release_date = Date.parse(mod.releases.first.updated_at).to_date
prev_release = Date.parse(mod.releases[1].updated_at).to_date
version = mod.releases.first.version
changelog = mod.releases.first.changelog
repo_metadata = JSON.parse(repo.file_content('metadata.json'))
repo_changelog = repo.file_content('CHANGELOG.md') || repo.file_content('CHANGELOG')
latest_tag = repo.tags.first.name
latest_tag_date = repo.commit_date(repo.tags.first.commit.sha)
if (Date.today - release_date) > 365
response << {
severity: :yellow,
message: "The most current module release is more than a year old.",
explanation: "Sometimes when issues are not responded to, it means that the project is no longer being maintained. You might consider contacting the maintainer to determine the status of the project.",
}
end
if version != repo_metadata[:version]
response << {
severity: :red,
message: "The version released on the Forge does not match the version in the repository.",
explanation: "Validate that the Forge release is not compromised and is the latest released version.",
}
end
if changelog != repo_changelog
response << {
severity: :green,
message: "The module changelog on the Forge does not match what's in the repository.",
explanation: "This is not necessarily a problem. Some developers choose to update the changelog iteratively as they merge pull requests instead of all at release time. Still, it's worth double checking.",
}
end
if version != latest_tag
response << {
severity: :yellow,
message: "The version released on the Forge does not match the latest tag in the repo.",
explanation: "This sometimes just indicates sloppy release practices, but could indicate a compromised Forge release.",
}
end
if release_date != latest_tag_date
response << {
severity: :yellow,
message: "The module was not published to the Forge on the same day that the latest release was tagged.",
explanation: "This sometimes just indicates sloppy release practices, but could indicate a compromised Forge release.",
}
end
if (release_date - prev_release) > 365
response << {
severity: :green,
message: "There was a gap of at least a year between the last two releases.",
explanation: "A large gap between releases often shows sporadic maintenance. This is not always bad.",
}
end
response
end
|