Class: StillActive::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/still_active/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



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/still_active/config.rb', line 38

def initialize
  @alternatives = false
  @unreleased_commits = false
  @direct_only = false
  @fail_if_critical = false
  @fail_if_poison = false
  @fail_if_language_ceiling = false
  @fail_if_outdated = nil
  @fail_if_vulnerable = nil
  @fail_if_warning = false
  @gemfile_path = nil
  @gems = []
  @ignored_gems = []
  @suppressions = Suppressions.from(nil)
  @github_oauth_token = nil
  @gitlab_token = nil
  @forgejo_token = nil
  @artifactory_token = nil
  @artifactory_host = nil
  @ecosystems_email = nil

  @parallelism = 10

  @output_format = :auto
  @sarif_path = nil
  @baseline_path = nil
  @cyclonedx_path = nil
  @cyclonedx_version = "1.6"

  @critical_warning_emoji = "🚩"
  @futurist_emoji = "🔮"
  @success_emoji = ""
  @unsure_emoji = ""
  @warning_emoji = "⚠️"

  # Release-age thresholds (years) calibrated against real RubyGems cadence,
  # not the npm-derived 12-month convention: healthy mature gems routinely go
  # 12-18 months between releases, so the ok ceiling is 18 months. > 3 years
  # is critical. See #32.
  @no_warning_range_end = 1.5
  @warning_range_end = 3
end

Instance Attribute Details

#alternativesObject

Returns the value of attribute alternatives.



12
13
14
# File 'lib/still_active/config.rb', line 12

def alternatives
  @alternatives
end

#artifactory_hostObject



127
128
129
# File 'lib/still_active/config.rb', line 127

def artifactory_host
  @artifactory_host ||= presence(ENV["STILL_ACTIVE_ARTIFACTORY_HOST"])
end

#artifactory_tokenObject



123
124
125
# File 'lib/still_active/config.rb', line 123

def artifactory_token
  @artifactory_token ||= presence(ENV["STILL_ACTIVE_ARTIFACTORY_TOKEN"])
end

#baseline_pathObject

Returns the value of attribute baseline_path.



12
13
14
# File 'lib/still_active/config.rb', line 12

def baseline_path
  @baseline_path
end

#critical_warning_emojiObject

Returns the value of attribute critical_warning_emoji.



12
13
14
# File 'lib/still_active/config.rb', line 12

def critical_warning_emoji
  @critical_warning_emoji
end

#cyclonedx_pathObject

Returns the value of attribute cyclonedx_path.



12
13
14
# File 'lib/still_active/config.rb', line 12

def cyclonedx_path
  @cyclonedx_path
end

#cyclonedx_versionObject

Returns the value of attribute cyclonedx_version.



12
13
14
# File 'lib/still_active/config.rb', line 12

def cyclonedx_version
  @cyclonedx_version
end

#direct_onlyObject

Returns the value of attribute direct_only.



12
13
14
# File 'lib/still_active/config.rb', line 12

def direct_only
  @direct_only
end

#ecosystems_emailObject

Codeberg/Forgejo has no ubiquitous CLI to borrow a token from (unlike gh/glab), so it's env-var only. Anonymous works for public repos; a token only raises the rate limit. CODEBERG_TOKEN is accepted as a convenience alias for the codeberg.org default host. Optional contact email for ecosyste.ms's "polite pool" (sent as a mailto query param), which raises the anonymous rate limit and lets them reach out. Nil by default -- anonymous is plenty for a typical lockfile.



115
116
117
# File 'lib/still_active/config.rb', line 115

def ecosystems_email
  @ecosystems_email ||= presence(ENV["STILL_ACTIVE_ECOSYSTEMS_EMAIL"]&.strip)
end

#fail_if_criticalObject

Returns the value of attribute fail_if_critical.



12
13
14
# File 'lib/still_active/config.rb', line 12

def fail_if_critical
  @fail_if_critical
end

#fail_if_language_ceilingObject

Returns the value of attribute fail_if_language_ceiling.



12
13
14
# File 'lib/still_active/config.rb', line 12

def fail_if_language_ceiling
  @fail_if_language_ceiling
end

#fail_if_outdatedObject

Returns the value of attribute fail_if_outdated.



12
13
14
# File 'lib/still_active/config.rb', line 12

def fail_if_outdated
  @fail_if_outdated
end

#fail_if_poisonObject

Returns the value of attribute fail_if_poison.



12
13
14
# File 'lib/still_active/config.rb', line 12

def fail_if_poison
  @fail_if_poison
end

#fail_if_vulnerableObject

Returns the value of attribute fail_if_vulnerable.



12
13
14
# File 'lib/still_active/config.rb', line 12

def fail_if_vulnerable
  @fail_if_vulnerable
end

#fail_if_warningObject

Returns the value of attribute fail_if_warning.



12
13
14
# File 'lib/still_active/config.rb', line 12

def fail_if_warning
  @fail_if_warning
end

#forgejo_tokenObject



119
120
121
# File 'lib/still_active/config.rb', line 119

def forgejo_token
  @forgejo_token ||= presence(ENV["STILL_ACTIVE_FORGEJO_TOKEN"]) || presence(ENV["CODEBERG_TOKEN"])
end

#futurist_emojiObject

Returns the value of attribute futurist_emoji.



12
13
14
# File 'lib/still_active/config.rb', line 12

def futurist_emoji
  @futurist_emoji
end

#gemfile_pathObject

Lazy so that running with --gems=... (no Gemfile needed) doesn't crash when invoked from a directory without a Gemfile in the tree.



133
134
135
136
137
138
139
# File 'lib/still_active/config.rb', line 133

def gemfile_path
  @gemfile_path ||= begin
    Bundler.default_gemfile.to_s
  rescue Bundler::GemfileNotFound
    File.join(Dir.pwd, "Gemfile")
  end
end

#gemsObject

Returns the value of attribute gems.



12
13
14
# File 'lib/still_active/config.rb', line 12

def gems
  @gems
end

#github_oauth_tokenObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/still_active/config.rb', line 86

def github_oauth_token
  # Cache the resolution including a nil result: the token can't change
  # mid-run, and provider selection now reads this per gem, so a plain ||=
  # (which doesn't memoize nil) would re-shell `gh auth token` for every gem
  # in a no-token run.
  return @github_oauth_token if @github_oauth_token_resolved

  # Assign before flipping the flag: gh_cli_token shells out and yields the
  # async reactor, so a concurrent fiber must never see resolved=true while
  # the value is still nil (it would wrongly route a tokened gem to the
  # ecosyste.ms fallback). Worst case under contention is a few extra `gh`
  # calls, never a premature nil; Workflow.call also resolves this once before
  # the fan-out so the contended path isn't normally hit.
  @github_oauth_token ||= presence(ENV["GITHUB_TOKEN"]) || presence(ENV["GH_TOKEN"]) || gh_cli_token
  @github_oauth_token_resolved = true
  @github_oauth_token
end

#gitlab_tokenObject



104
105
106
# File 'lib/still_active/config.rb', line 104

def gitlab_token
  @gitlab_token ||= presence(ENV["GITLAB_TOKEN"]) || glab_cli_token
end

#ignored_gemsObject

Returns the value of attribute ignored_gems.



12
13
14
# File 'lib/still_active/config.rb', line 12

def ignored_gems
  @ignored_gems
end

#no_warning_range_endObject

Returns the value of attribute no_warning_range_end.



12
13
14
# File 'lib/still_active/config.rb', line 12

def no_warning_range_end
  @no_warning_range_end
end

#output_formatObject

Returns the value of attribute output_format.



12
13
14
# File 'lib/still_active/config.rb', line 12

def output_format
  @output_format
end

#parallelismObject

Returns the value of attribute parallelism.



12
13
14
# File 'lib/still_active/config.rb', line 12

def parallelism
  @parallelism
end

#sarif_pathObject

Returns the value of attribute sarif_path.



12
13
14
# File 'lib/still_active/config.rb', line 12

def sarif_path
  @sarif_path
end

#sbom_pathObject

Returns the value of attribute sbom_path.



11
12
13
# File 'lib/still_active/config.rb', line 11

def sbom_path
  @sbom_path
end

#success_emojiObject

Returns the value of attribute success_emoji.



12
13
14
# File 'lib/still_active/config.rb', line 12

def success_emoji
  @success_emoji
end

#suppressionsObject

Returns the value of attribute suppressions.



12
13
14
# File 'lib/still_active/config.rb', line 12

def suppressions
  @suppressions
end

#unreleased_commitsObject

Returns the value of attribute unreleased_commits.



12
13
14
# File 'lib/still_active/config.rb', line 12

def unreleased_commits
  @unreleased_commits
end

#unsure_emojiObject

Returns the value of attribute unsure_emoji.



12
13
14
# File 'lib/still_active/config.rb', line 12

def unsure_emoji
  @unsure_emoji
end

#warning_emojiObject

Returns the value of attribute warning_emoji.



12
13
14
# File 'lib/still_active/config.rb', line 12

def warning_emoji
  @warning_emoji
end

#warning_range_endObject

Returns the value of attribute warning_range_end.



12
13
14
# File 'lib/still_active/config.rb', line 12

def warning_range_end
  @warning_range_end
end

Instance Method Details

#github_clientObject



81
82
83
84
# File 'lib/still_active/config.rb', line 81

def github_client
  @github_client ||=
    Octokit::Client.new(access_token: github_oauth_token)
end