Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

Commit

Permalink
Merge 35238a0 into be6ef96
Browse files Browse the repository at this point in the history
  • Loading branch information
scouten committed Jul 14, 2019
2 parents be6ef96 + 35238a0 commit 0fab9e5
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 4 deletions.
106 changes: 106 additions & 0 deletions .credo.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
%{
configs: [
%{
name: "default",

files: %{
included: ["lib/", "test/"],
excluded: [~r"/_build/", ~r"/deps/"]
},

requires: [],
strict: true,

color: true,

checks: [
# Consistency Checks

{Credo.Check.Consistency.ExceptionNames, []},
{Credo.Check.Consistency.LineEndings, []},
{Credo.Check.Consistency.ParameterPatternMatching, []},
{Credo.Check.Consistency.SpaceAroundOperators, []},
{Credo.Check.Consistency.SpaceInParentheses, []},
{Credo.Check.Consistency.TabsOrSpaces, []},

# Design Checks

{Credo.Check.Design.AliasUsage,
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
{Credo.Check.Design.TagTODO, [exit_status: 2]},
{Credo.Check.Design.TagFIXME, []},

# Readability Checks

{Credo.Check.Readability.AliasOrder, []},
{Credo.Check.Readability.FunctionNames, []},
{Credo.Check.Readability.LargeNumbers, []},
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
{Credo.Check.Readability.ModuleAttributeNames, []},
{Credo.Check.Readability.ModuleDoc, []},
{Credo.Check.Readability.ModuleNames, []},
{Credo.Check.Readability.ParenthesesInCondition, []},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
{Credo.Check.Readability.PredicateFunctionNames, []},
{Credo.Check.Readability.PreferImplicitTry, []},
{Credo.Check.Readability.RedundantBlankLines, []},
{Credo.Check.Readability.Semicolons, []},
{Credo.Check.Readability.SpaceAfterCommas, []},
{Credo.Check.Readability.StringSigils, []},
{Credo.Check.Readability.TrailingBlankLine, []},
{Credo.Check.Readability.TrailingWhiteSpace, []},
{Credo.Check.Readability.VariableNames, []},

# Refactoring Opportunities

{Credo.Check.Refactor.CondStatements, []},
{Credo.Check.Refactor.CyclomaticComplexity, []},
{Credo.Check.Refactor.FunctionArity, []},
{Credo.Check.Refactor.LongQuoteBlocks, []},
{Credo.Check.Refactor.MapInto, false},
{Credo.Check.Refactor.MatchInCondition, []},
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.Nesting, []},
{Credo.Check.Refactor.PipeChainStart,
[
excluded_argument_types: [:atom, :binary, :fn, :keyword, :number],
excluded_functions: []
]},
{Credo.Check.Refactor.UnlessWithElse, []},

# Warnings

{Credo.Check.Warning.BoolOperationOnSameValues, []},
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
{Credo.Check.Warning.IExPry, []},
{Credo.Check.Warning.IoInspect, []},
{Credo.Check.Warning.LazyLogging, false},
{Credo.Check.Warning.OperationOnSameValues, []},
{Credo.Check.Warning.OperationWithConstantResult, []},
{Credo.Check.Warning.RaiseInsideRescue, []},
{Credo.Check.Warning.UnusedEnumOperation, []},
{Credo.Check.Warning.UnusedFileOperation, []},
{Credo.Check.Warning.UnusedKeywordOperation, []},
{Credo.Check.Warning.UnusedListOperation, []},
{Credo.Check.Warning.UnusedPathOperation, []},
{Credo.Check.Warning.UnusedRegexOperation, []},
{Credo.Check.Warning.UnusedStringOperation, []},
{Credo.Check.Warning.UnusedTupleOperation, []},

# Controversial and experimental checks (opt-in, just replace `false` with `[]`)

{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
{Credo.Check.Design.DuplicatedCode, false},
{Credo.Check.Readability.Specs, []},
{Credo.Check.Refactor.ABCSize, false},
{Credo.Check.Refactor.AppendSingleItem, false},
{Credo.Check.Refactor.DoubleBooleanNegation, false},
{Credo.Check.Refactor.ModuleDependencies, false},
{Credo.Check.Refactor.VariableRebinding, false},
{Credo.Check.Warning.MapGetUnsafePass, false},
{Credo.Check.Warning.UnsafeToAtom, false}
]
}
]
}
1 change: 1 addition & 0 deletions lib/xgit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule Xgit do
@doc """
Start Xgit application.
"""
@impl true
def start(_type, _args) do
children = []
Supervisor.start_link(children, strategy: :one_for_one)
Expand Down
5 changes: 3 additions & 2 deletions lib/xgit/core/object.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ defmodule Xgit.Core.Object do
## Options
`:type`: the object's type (default: `:blob`)
`:content`: how to obtain the content (see `Xgit.Core.ContentSource`)
* `:type`: the object's type (default: `:blob`)
* `:content`: how to obtain the content (see `Xgit.Core.ContentSource`)
"""
@spec new(type: ObjectType.t() | nil, content: ContentSource.t()) :: t
def new(opts) when is_list(opts) do
type = Keyword.get(opts, :type, :blob)

Expand Down
3 changes: 1 addition & 2 deletions lib/xgit/repository/on_disk.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ defmodule Xgit.Repository.OnDisk do
That said, it does intentionally use the same `.git` folder format as command-line
`git` so that results may be compared for similar operations.
"""

use Xgit.Repository

@doc ~S"""
Expand All @@ -32,7 +31,7 @@ defmodule Xgit.Repository.OnDisk do
@spec start_link(opts :: Keyword.t()) :: GenServer.on_start()
def start_link(opts \\ []), do: Repository.start_link(__MODULE__, opts, opts)

@impl GenServer
@impl true
def init(opts) when is_list(opts) do
work_dir = Keyword.get(opts, :work_dir)

Expand Down
1 change: 1 addition & 0 deletions lib/xgit/repository/on_disk/create.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule Xgit.Repository.OnDisk.Create do
@moduledoc false
# Implements Xgit.Repository.OnDisk.create/1.

@spec create!(work_dir: String.t()) :: :ok
def create!(opts) when is_list(opts) do
work_dir = Keyword.get(opts, :work_dir)

Expand Down
1 change: 1 addition & 0 deletions test/support/folder_diff.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule FolderDiff do

import ExUnit.Assertions

@spec assert_folders_are_equal(folder1 :: Path.t(), folder2 :: Path.t()) :: :ok
def assert_folders_are_equal(folder1, folder2) do
files1 = folder1 |> File.ls!() |> Enum.sort()
files2 = folder2 |> File.ls!() |> Enum.sort()
Expand Down

0 comments on commit 0fab9e5

Please sign in to comment.