Re-run dotnet format and enable style enforcement. (#8053)

This commit is contained in:
Cory 2020-04-07 11:17:17 -05:00 committed by GitHub
parent 4f9670413d
commit 6dc00de864
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 1399 additions and 1355 deletions

View File

@ -254,9 +254,52 @@ stages:
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
- stage: CodeStyle
displayName: Code Style Compliance
dependsOn: []
jobs:
- job: Linting
pool:
vmImage: ubuntu-latest
workspace:
clean: all
steps:
- checkout: self
- task: UseDotNet@2
displayName: Install .NET Core SDK
inputs:
packageType: sdk
version: $(netCoreSdkVersion)
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
displayName: Install Dotnet Format
inputs:
command: custom
custom: tool
arguments: update -g dotnet-format
- task: Bash@3
displayName: Lint Dotnet
inputs:
workingDirectory: $(Build.SourcesDirectory)
targetType: inline
failOnStderr: true
script: |
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/DateTimeRoutines
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Common
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.IntegrationTests
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Server
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Service
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Test
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Tray
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Updater
- stage: UnitTestJackett
displayName: Unit Tests
dependsOn: CodeStyle
jobs:
- job: UnitTest
workspace:

View File

@ -155,7 +155,7 @@ namespace Jackett.Common.Indexers.Abstract
.Replace("text-pink", string.Empty);
release.Category = MapTrackerCatToNewznab(cat.Trim());
var grabs =row.QuerySelector("td:nth-child(9)").Text();
var grabs = row.QuerySelector("td:nth-child(9)").Text();
release.Grabs = ParseUtil.CoerceInt(grabs);
if (row.QuerySelectorAll("i.fa-star").Any())
@ -185,7 +185,7 @@ namespace Jackett.Common.Indexers.Abstract
try
{
var imdbUrl = IMDBSearch + imdbId;
var imdbHeaders = new Dictionary<string, string> { {"X-Requested-With", "XMLHttpRequest"} };
var imdbHeaders = new Dictionary<string, string> { { "X-Requested-With", "XMLHttpRequest" } };
var imdbResponse = await RequestStringWithCookiesAndRetry(imdbUrl, null, null, imdbHeaders);
if (imdbResponse.IsRedirect)
{

View File

@ -87,7 +87,7 @@ namespace Jackett.Common.Indexers
qc.Add("action", "latestmovies");
// the endpoint 'latestmovies' only returns movies, this hack overwrites categories to get movies even if
// you are searching for tv series. this allows to configure the tracker in Sonarr
query.Categories = new int[] {};
query.Categories = new int[] { };
}
var searchUrl = SearchUrl + "?" + qc.GetQueryString();

View File

@ -253,14 +253,14 @@ namespace Jackett.Common.Indexers
release.Description += line + "\n";
if (line.Contains(":"))
{
if(!(line.StartsWith("Lançado") || line.StartsWith("Resolução") || line.StartsWith("Idioma") || line.StartsWith("Autor")))
if (!(line.StartsWith("Lançado") || line.StartsWith("Resolução") || line.StartsWith("Idioma") || line.StartsWith("Autor")))
{
var info = line.Substring(line.IndexOf(": ") + 2);
if (info == "Dual Áudio")
{
info = "Dual";
}
extra_info += info + " ";
extra_info += info + " ";
}
}
}

View File

@ -105,11 +105,11 @@ namespace Jackett.Common.Indexers
return new ConfigurationDataBasicLogin
{
SiteLink = {Value = configData.SiteLink.Value},
Instructions = {Value = configData.Instructions.Value},
Username = {Value = configData.Username.Value},
Password = {Value = configData.Password.Value},
CookieHeader = {Value = loginPage.Cookies}
SiteLink = { Value = configData.SiteLink.Value },
Instructions = { Value = configData.Instructions.Value },
Username = { Value = configData.Username.Value },
Password = { Value = configData.Password.Value },
CookieHeader = { Value = loginPage.Cookies }
};
}

View File

@ -122,7 +122,7 @@ namespace Jackett.Common.Indexers
PublishDate = lastPublishDate,
BannerUrl = banner,
Description = description,
Category = new List<int> {TorznabCatType.BooksEbook.ID},
Category = new List<int> { TorznabCatType.BooksEbook.ID },
Size = 5242880, // 5 MB
Seeders = 1,
Peers = 2,
@ -151,7 +151,8 @@ namespace Jackett.Common.Indexers
var result = await RequestStringWithCookiesAndRetry(link.AbsoluteUri);
if (SobrecargaUrl.Equals(result.RedirectingTo))
throw new Exception("El servidor se encuentra sobrecargado en estos momentos. / The server is currently overloaded.");
try {
try
{
var parser = new HtmlParser();
var doc = parser.ParseDocument(result.Content);
var magnetLink = doc.QuerySelector("a[id=en_desc]").GetAttribute("href");

View File

@ -29,7 +29,7 @@ namespace Jackett.Common.Indexers.Feeds
protected virtual ReleaseInfo ResultFromFeedItem(XElement item)
{
var attributes = item.Descendants().Where(e => e.Name.LocalName == "attr");
var size = long.TryParse(ReadAttribute(attributes, "size"), out var longVal ) ? (long?)longVal : null;
var size = long.TryParse(ReadAttribute(attributes, "size"), out var longVal) ? (long?)longVal : null;
var files = long.TryParse(ReadAttribute(attributes, "files"), out longVal) ? (long?)longVal : null;
var seeders = int.TryParse(ReadAttribute(attributes, "seeders"), out var intVal) ? (int?)intVal : null;
var peers = int.TryParse(ReadAttribute(attributes, "peers"), out intVal) ? (int?)intVal : null;

View File

@ -129,8 +129,8 @@ namespace Jackett.Common.Indexers
var leechers = ParseUtil.CoerceInt(row.Children[10].TextContent);
var ka = row.NextElementSibling.QuerySelector("table > tbody > tr:nth-child(3)");
var ulFactor = ParseUtil.CoerceDouble(ka.Children[0].TextContent.Replace("X", ""));
var dlFactor = ParseUtil.CoerceDouble(ka.Children[1].TextContent.Replace("X", ""));
var ulFactor = ParseUtil.CoerceDouble(ka.Children[0].TextContent.Replace("X", ""));
var dlFactor = ParseUtil.CoerceDouble(ka.Children[1].TextContent.Replace("X", ""));
var release = new ReleaseInfo
{

View File

@ -91,16 +91,16 @@ namespace Jackett.Common.Indexers
var categories = MapTorznabCapsToTrackers(query);
if(categories.Any())
if (categories.Any())
requestData.Add("category", JToken.FromObject(categories));
if(configData.Codecs.Values.Any())
if (configData.Codecs.Values.Any())
requestData.Add("codec", JToken.FromObject(configData.Codecs.Values.Select(int.Parse)));
if(configData.Mediums.Values.Any())
if (configData.Mediums.Values.Any())
requestData.Add("medium", JToken.FromObject(configData.Mediums.Values.Select(int.Parse)));
if(configData.Origins.Values.Any())
if (configData.Origins.Values.Any())
requestData.Add("origin", JToken.FromObject(configData.Origins.Values.Select(int.Parse)));
requestData["limit"] = 100;

View File

@ -172,7 +172,7 @@ namespace Jackett.Common.Indexers
publishDate = DateTime.Parse((string)torrent["created_at"]);
Uri bannerUrl = null;
if (torrent["portada"] != null)
bannerUrl = new Uri(BannerUrl + (string)(torrent["portada"]["hash"]) + "." + (string)(torrent["portada"]["ext"]));
bannerUrl = new Uri(BannerUrl + (string)(torrent["portada"]["hash"]) + "." + (string)(torrent["portada"]["ext"]));
var seeders = (int)torrent["seeders"];
var link = new Uri(DownloadUrl + (string)torrent["id"]);

View File

@ -140,9 +140,9 @@ namespace Jackett.Common.Indexers
release.Guid = release.Comments;
var imdbLink = row.Children[1].QuerySelector("a[href*=imdb]");
if(imdbLink != null)
if (imdbLink != null)
release.Imdb = ParseUtil.GetImdbID(imdbLink.GetAttribute("href").Split('/').Last());
var qDownload = row.Children[3].FirstElementChild;
release.Link = new Uri(SiteLink + qDownload.GetAttribute("href"));

View File

@ -723,7 +723,7 @@ namespace Jackett.Common.Indexers
// TODO this feels sparse compared to other trackers. Expand later
var release = new ReleaseInfo
{
Category = new[] {TorznabCatType.TV.ID},
Category = new[] { TorznabCatType.TV.ID },
Title = string.Join(" - ", titleComponents.Where(s => !string.IsNullOrEmpty(s))),
Link = link,
Guid = link,
@ -736,7 +736,7 @@ namespace Jackett.Common.Indexers
MinimumRatio = 1,
MinimumSeedTime = 172800 // 48 hours
};
// TODO Other trackers don't have this log line. Remove or add to other trackers?
logger.Debug("> Add: " + release.Title);
releases.Add(release);

View File

@ -36,11 +36,11 @@ namespace Jackett.Common.Indexers.Meta
public async Task<IEnumerable<TorznabQuery>> FallbackQueries()
{
if(string.IsNullOrEmpty(query.ImdbID))
return Enumerable.Empty<TorznabQuery>();
var title = (await resolver.MovieForId(query.ImdbID)).Title;
return title != null ? new[] {query.CreateFallback(title)} : Enumerable.Empty<TorznabQuery>();
}
if (string.IsNullOrEmpty(query.ImdbID))
return Enumerable.Empty<TorznabQuery>();
var title = (await resolver.MovieForId(query.ImdbID)).Title;
return title != null ? new[] { query.CreateFallback(title) } : Enumerable.Empty<TorznabQuery>();
}
private readonly IImdbResolver resolver;
private readonly TorznabQuery query;

View File

@ -313,7 +313,7 @@ namespace Jackett.Common.Indexers
results = await RequestStringWithCookiesAndRetry(seriesEpisodesUrl);
var items = ParseEpisodesListContent(results.Content);
if (items != null && items.Any())
releases.AddRange(items);
releases.AddRange(items);
}
return releases;
}

View File

@ -95,7 +95,7 @@ namespace Jackett.Common.Indexers
var movieListSearchUrl = SearchUrl;
var queryCollection = new NameValueCollection {{"json", "noredirect"}};
var queryCollection = new NameValueCollection { { "json", "noredirect" } };
if (!string.IsNullOrEmpty(query.ImdbID))
queryCollection.Add("searchstr", query.ImdbID);

View File

@ -186,7 +186,7 @@ namespace Jackett.Common.Indexers
MinimumRatio = 1,
MinimumSeedTime = 72 * 60 * 60,
Title = group + " " + title.TextContent,
Category = new List<int> {TorznabCatType.MoviesHD.ID},
Category = new List<int> { TorznabCatType.MoviesHD.ID },
Link = link,
Comments = comments,
Guid = link,

View File

@ -156,10 +156,10 @@ namespace Jackett.Common.Indexers
var dateStr = qPudDate.Text().Trim();
DateTime pubDateUtc;
if (dateStr.StartsWith("Today "))
pubDateUtc = DateTime.SpecifyKind(DateTime.UtcNow.Date, DateTimeKind.Unspecified) + DateTime.ParseExact(dateStr.Split(new [] { ' ' }, 2)[1], "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay;
pubDateUtc = DateTime.SpecifyKind(DateTime.UtcNow.Date, DateTimeKind.Unspecified) + DateTime.ParseExact(dateStr.Split(new[] { ' ' }, 2)[1], "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay;
else if (dateStr.StartsWith("Yesterday "))
pubDateUtc = DateTime.SpecifyKind(DateTime.UtcNow.Date, DateTimeKind.Unspecified) +
DateTime.ParseExact(dateStr.Split(new [] { ' ' }, 2)[1], "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay - TimeSpan.FromDays(1);
DateTime.ParseExact(dateStr.Split(new[] { ' ' }, 2)[1], "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay - TimeSpan.FromDays(1);
else
pubDateUtc = DateTime.SpecifyKind(DateTime.ParseExact(dateStr, "MMM d yyyy hh:mm tt", CultureInfo.InvariantCulture), DateTimeKind.Unspecified);

View File

@ -122,10 +122,10 @@ namespace Jackett.Common.Indexers
{
var stdResult = new ConfigurationDataBasicLogin
{
SiteLink = {Value = configData.SiteLink.Value},
Username = {Value = configData.Username.Value},
Password = {Value = configData.Password.Value},
CookieHeader = {Value = loginPage.Cookies}
SiteLink = { Value = configData.SiteLink.Value },
Username = { Value = configData.Username.Value },
Password = { Value = configData.Password.Value },
CookieHeader = { Value = loginPage.Cookies }
};
return stdResult;
}

View File

@ -162,8 +162,8 @@ namespace Jackett.Common.Indexers
}
foreach (var release in releases)
release.Category = release.Title.Contains("1080p") || release.Title.Contains("720p")
? new List<int> {TorznabCatType.TVHD.ID}
: new List<int> {TorznabCatType.TVSD.ID};
? new List<int> { TorznabCatType.TVHD.ID }
: new List<int> { TorznabCatType.TVSD.ID };
return releases;
}

View File

@ -89,7 +89,7 @@ namespace Jackett.Common.Indexers
MinimumSeedTime = 172800, // 48 hours
Title = title,
Comments = magnetUri,
Category = new List<int> {category},
Category = new List<int> { category },
Guid = guid,
PublishDate = publishDate,
Description = infoHash,

View File

@ -120,7 +120,7 @@ namespace Jackett.Common.Indexers
var size = ReleaseInfo.GetBytes(Size.TextContent);
var grabs = ParseUtil.CoerceLong(Grabs.TextContent);
var files = ParseUtil.CoerceLong(Files.TextContent);
var category = new List<int> {TvCategoryParser.ParseTvShowQuality(description)};
var category = new List<int> { TvCategoryParser.ParseTvShowQuality(description) };
var release = new ReleaseInfo
{
MinimumRatio = 1,

View File

@ -141,7 +141,7 @@ namespace Jackett.Common.Indexers
.Select((str, index) => (index, str)) //Index each string for grouping
.GroupBy(n => n.index / 27) // each torrent is divided into 27 parts
.Skip(previouslyParsedOnPage).Take(maxTorrents)// only parse the rows we want
//Convert above query into a List<string>(27) in prep for parsing
//Convert above query into a List<string>(27) in prep for parsing
.Select(entry => entry.Select(item => item.str).ToList());
foreach (var row in rows)
{

View File

@ -120,11 +120,11 @@ namespace Jackett.Common.Indexers
{
var result = new ConfigurationDataBasicLogin
{
SiteLink = {Value = configData.SiteLink.Value},
Instructions = {Value = configData.Instructions.Value},
Username = {Value = configData.Username.Value},
Password = {Value = configData.Password.Value},
CookieHeader = {Value = loginPage.Cookies}
SiteLink = { Value = configData.SiteLink.Value },
Instructions = { Value = configData.Instructions.Value },
Username = { Value = configData.Username.Value },
Password = { Value = configData.Password.Value },
CookieHeader = { Value = loginPage.Cookies }
};
return result;
}

View File

@ -155,7 +155,7 @@ namespace Jackett.Common.Indexers
var tvEpisode = query.GetEpisodeSearchString();
if (!string.IsNullOrWhiteSpace(tvEpisode))
{
if(tvEpisode.StartsWith("S") && !tvEpisode.Contains("E"))
if (tvEpisode.StartsWith("S") && !tvEpisode.Contains("E"))
tvEpisode += "*";
searchStringArray = searchStringArray.Append($"+{tvEpisode}");
}
@ -202,7 +202,7 @@ namespace Jackett.Common.Indexers
var dateStr = rawDateStr.Replace("von", "")
.Replace("Heute", "Today")
.Replace("Gestern", "Yesterday");
var dateGerman =DateTimeUtil.FromUnknown(dateStr);
var dateGerman = DateTimeUtil.FromUnknown(dateStr);
var pubDateUtc = TimeZoneInfo.ConvertTimeToUtc(dateGerman, germanyTz);
var longFromString = ParseUtil.GetLongFromString(descCol.QuerySelector("a[href*=\"&searchin=imdb\"]")?.GetAttribute("href"));
var sizeFileCountRowChilds = row.Children[5].Children;

View File

@ -102,7 +102,7 @@ namespace Jackett.Common.Indexers
// TODO dynamically generate list periodically from online tracker repositories like
// https://torrents.io/tracker-list/
// https://github.com/ngosang/trackerslist
var magnet = new Uri( "magnet:?xt=urn:btih:" + torrent.Value<JToken>("infohash") +
var magnet = new Uri("magnet:?xt=urn:btih:" + torrent.Value<JToken>("infohash") +
"&tr=udp://tracker.coppersurfer.tk:6969/announce" +
"&tr=udp://tracker.leechers-paradise.org:6969/announce" +
"&tr=udp://tracker.internetwarriors.net:1337/announce" +

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@ namespace Jackett.Common.Models.IndexerConfig
public StringItem Pin { get; private set; }
public ConfigurationDataPinNumber(string instructionMessageOptional = null)
: base (instructionMessageOptional)
: base(instructionMessageOptional)
=> Pin = new StringItem { Name = "Login Pin Number" };
}
}

View File

@ -102,7 +102,7 @@ namespace Jackett.Server.Services
{
var firstLine = reader.ReadLine();
if (firstLine != null)
logger.Info( $"File {issueFile}: {firstLine}");
logger.Info($"File {issueFile}: {firstLine}");
}
}
catch (Exception e)

View File

@ -25,7 +25,7 @@ namespace Jackett.Common.Utils.Tests
};
foreach (var testCase in testCases)
Assert.AreEqual( testCase.Value, DateTimeUtil.FromUnknown(testCase.Key));
Assert.AreEqual(testCase.Value, DateTimeUtil.FromUnknown(testCase.Key));
}
}
}