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.



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
# File 'lib/still_active/config.rb', line 35

def initialize
  @alternatives = false
  @unreleased_commits = false
  @direct_only = false
  @fail_if_critical = 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

  @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.



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

def alternatives
  @alternatives
end

#artifactory_hostObject



100
101
102
# File 'lib/still_active/config.rb', line 100

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

#artifactory_tokenObject



96
97
98
# File 'lib/still_active/config.rb', line 96

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

#baseline_pathObject

Returns the value of attribute baseline_path.



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

def baseline_path
  @baseline_path
end

#critical_warning_emojiObject

Returns the value of attribute critical_warning_emoji.



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

def critical_warning_emoji
  @critical_warning_emoji
end

#cyclonedx_pathObject

Returns the value of attribute cyclonedx_path.



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

def cyclonedx_path
  @cyclonedx_path
end

#cyclonedx_versionObject

Returns the value of attribute cyclonedx_version.



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

def cyclonedx_version
  @cyclonedx_version
end

#direct_onlyObject

Returns the value of attribute direct_only.



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

def direct_only
  @direct_only
end

#fail_if_criticalObject

Returns the value of attribute fail_if_critical.



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

def fail_if_critical
  @fail_if_critical
end

#fail_if_outdatedObject

Returns the value of attribute fail_if_outdated.



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

def fail_if_outdated
  @fail_if_outdated
end

#fail_if_vulnerableObject

Returns the value of attribute fail_if_vulnerable.



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

def fail_if_vulnerable
  @fail_if_vulnerable
end

#fail_if_warningObject

Returns the value of attribute fail_if_warning.



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

def fail_if_warning
  @fail_if_warning
end

#forgejo_tokenObject

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.



92
93
94
# File 'lib/still_active/config.rb', line 92

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.



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

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.



106
107
108
109
110
111
112
# File 'lib/still_active/config.rb', line 106

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.



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

def gems
  @gems
end

#github_oauth_tokenObject



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

def github_oauth_token
  @github_oauth_token ||= presence(ENV["GITHUB_TOKEN"]) || presence(ENV["GH_TOKEN"]) || gh_cli_token
end

#gitlab_tokenObject



84
85
86
# File 'lib/still_active/config.rb', line 84

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

#ignored_gemsObject

Returns the value of attribute ignored_gems.



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

def ignored_gems
  @ignored_gems
end

#no_warning_range_endObject

Returns the value of attribute no_warning_range_end.



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

def no_warning_range_end
  @no_warning_range_end
end

#output_formatObject

Returns the value of attribute output_format.



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

def output_format
  @output_format
end

#parallelismObject

Returns the value of attribute parallelism.



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

def parallelism
  @parallelism
end

#sarif_pathObject

Returns the value of attribute sarif_path.



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

def sarif_path
  @sarif_path
end

#success_emojiObject

Returns the value of attribute success_emoji.



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

def success_emoji
  @success_emoji
end

#suppressionsObject

Returns the value of attribute suppressions.



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

def suppressions
  @suppressions
end

#unreleased_commitsObject

Returns the value of attribute unreleased_commits.



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

def unreleased_commits
  @unreleased_commits
end

#unsure_emojiObject

Returns the value of attribute unsure_emoji.



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

def unsure_emoji
  @unsure_emoji
end

#warning_emojiObject

Returns the value of attribute warning_emoji.



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

def warning_emoji
  @warning_emoji
end

#warning_range_endObject

Returns the value of attribute warning_range_end.



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

def warning_range_end
  @warning_range_end
end

Instance Method Details

#github_clientObject



75
76
77
78
# File 'lib/still_active/config.rb', line 75

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