Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions .ameba.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# This configuration file was generated by `ameba --gen-config`
# on 2025-06-02 13:57:07 UTC using Ameba version 1.7.0-dev.
# The point is for the user to remove these configuration records
# one by one as the reported problems are removed from the code base.
#
# For more details on any individual rule, run `ameba --only RuleName`.

# Indicators for comment annotations:
#
# * `Disabled`: The rule is disabled because it does not seem useful for this repo (or in general).
# * `BUG`: A bug in ameba prevents using this rule either entirely or for specific files.
# * `FIXME`: The rule seems useful, but requires some effort to resolve. That's deferred for later.
# * `TODO`: The rule might be useful, but we need to investigate whether we want to use it or not.

Version: "1.7.0-dev"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's incorrect.

Suggested change
Version: "1.7.0-dev"
Version: "1.7.0"


# Documentation
# =========================

# Disabled: What's the point in alerting about existing TODOs in code?
Documentation/DocumentationAdmonition:
Enabled: false

# Lint
# =========================

# Disabled: `else nil` can be useful to explicitly show the consequence of the else branch
Lint/ElseNil:
Enabled: false

# Disabled: We have an explicit CI job for testing the formatter (both latest
# and head). No reason to run it through ameba.
Lint/Formatting:
Enabled: false

# TODO: Investigate if some `not_nil!` calls can be avoided.
Lint/NotNil:
Enabled: false

# FIXME: Resolve shadowing.
Lint/ShadowingOuterLocalVar:
Enabled: false

# BUG: https://github.com/crystal-ameba/ameba/issues/612
Lint/TopLevelOperatorDefinition:
Enabled: false

# Disabled: We have an explicit CI job for `typos`. No reason to run it through
# ameba.
Lint/Typos:
Enabled: false

# TODO: Investigate unused arguments.
Lint/UnusedArgument:
Enabled: false

# TODO: Investigate unused block arguments.
Lint/UnusedBlockArgument:
Enabled: false

Lint/UselessAssign:
# BUG: https://github.com/crystal-ameba/ameba/issues/447
# This setting is to avoid false positives from the common use of type
# declarations in macro arguments.
ExcludeTypeDeclarations: true

# Metrics
# =========================

# Disabled: Lot's of violations. Complexity is very individual.
Metrics/CyclomaticComplexity:
Enabled: false

# Naming
# =========================
# All disabled. There are many violations and some of the rules are questionable.
# TODO: Consider enabling some of these rules.

Naming/AccessorMethodName:
Enabled: false

Naming/BinaryOperatorParameterName:
Enabled: false

Naming/BlockParameterName:
Enabled: false

# Disabled: All violations follow the spelling of identifiers in upstream
# projects, e.g. for lib bindings.
Naming/ConstantNames:
Enabled: false

Naming/MethodNames:
Enabled: false

Naming/PredicateName:
Enabled: false

Naming/QueryBoolMethods:
Enabled: false

Naming/RescuedExceptionsVariableName:
Enabled: false

Naming/TypeNames:
Enabled: false

Naming/VariableNames:
Enabled: false

# Style
# =========================
# All disabled. There are many violations and some of the rules are questionable.
# TODO: Consider enabling some of these rules.

Style/HeredocEscape:
Enabled: false

Style/HeredocIndent:
Enabled: false

Style/MultilineCurlyBlock:
Enabled: false

# Disabled: This rule seems too strict when any negation inside a complex condition is
# considered a violation. https://github.com/crystal-ameba/ameba/issues/621
Style/NegatedConditionsInUnless:
Enabled: false

# BUG: https://github.com/crystal-ameba/ameba/issues/614
Style/ParenthesesAroundCondition:
Enabled: false

Style/PercentLiteralDelimiters:
Enabled: false

Style/RedundantNext:
Enabled: false

Style/RedundantReturn:
Enabled: false

Style/RedundantSelf:
Enabled: false

Style/VerboseBlock:
Enabled: false

Style/WhileTrue:
Enabled: false
8 changes: 8 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@

git-hooks.hooks = {
actionlint.enable = true;
ameba = {
enable = true;
name = "Ameba";
entry = "${pkgs.ameba}/bin/ameba --fix";
files = "\\.cr$";
excludes = ["^lib/"];
pass_filenames = true;
};
check-toml.enable = true;
check-vcs-permalinks.enable = true;
circleci.enable = true;
Expand Down
2 changes: 0 additions & 2 deletions spec/integration/install_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@ describe "install" do
override = {dependencies: {
awesome: {git: git_url(:forked_awesome), branch: "feature/super"},
}}
expected_commit = git_commits(:forked_awesome).first

with_shard(metadata, lock, override) do
ex = expect_raises(FailedCommand) { run "shards install --no-color --#{flag}" }
Expand All @@ -551,7 +550,6 @@ describe "install" do
override = {dependencies: {
awesome: {git: git_url(:forked_awesome), branch: "feature/super"},
}}
expected_commit = git_commits(:forked_awesome).first

with_shard(metadata, lock, override) do
ex = expect_raises(FailedCommand) { run "shards install --no-color --#{flag}" }
Expand Down
4 changes: 2 additions & 2 deletions spec/support/factories.cr
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def fossil_commits(project, rev = "trunk")
end

retLines.reject! &.nil?
[/artifact:\s+(.+)/.match(run("fossil whatis #{retLines[0]}")).not_nil!.[1]]
[/artifact:\s+(.+)/.match!(run("fossil whatis #{retLines[0]}")).[1]]
end
end

Expand All @@ -321,7 +321,7 @@ def fossil_url(project)
end

def fossil_path(project)
File.join(tmp_path, "#{project.to_s}")
File.join(tmp_path, "#{project}")
end

def rel_path(project)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/check.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end

private def has_dependencies?
spec.dependencies.any? || (Shards.with_development? && spec.development_dependencies.any?)
spec.dependencies.present? || (Shards.with_development? && spec.development_dependencies.present?)

Check failure on line 18 in src/commands/check.cr

View workflow job for this annotation

GitHub Actions / test (ubuntu-22.04, 1.0.0)

undefined method 'present?' for Array(Shards::Dependency)
end

private def verify(dependencies)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/list.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Shards

# FIXME: duplicates Check#has_dependencies?
private def has_dependencies?
spec.dependencies.any? || (Shards.with_development? && spec.development_dependencies.any?)
spec.dependencies.present? || (Shards.with_development? && spec.development_dependencies.present?)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/commands/outdated.cr
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ module Shards

# FIXME: duplicates Check#has_dependencies?
private def has_dependencies?
spec.dependencies.any? || (Shards.with_development? && spec.development_dependencies.any?)
spec.dependencies.present? || (Shards.with_development? && spec.development_dependencies.present?)
end

private def dependency_by_name(name : String)
Expand Down
2 changes: 1 addition & 1 deletion src/molinillo_solver.cr
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ module Shards

@search_results[{dependency.name, dependency.requirement}] ||= begin
resolver = dependency.resolver
versions = Versions.sort(versions_for(dependency, resolver)).reverse
versions = Versions.sort(versions_for(dependency, resolver)).reverse!
result = versions.map do |version|
@specs[{dependency.name, version}] ||= begin
resolver.spec(version).tap do |spec|
Expand Down
2 changes: 1 addition & 1 deletion src/target.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Shards
main = nil

pull.each_in_mapping do
case key = pull.read_scalar
case pull.read_scalar
when "main"
main = pull.read_scalar
else
Expand Down
Loading